Files
Enterprise-Knowledge-Base/internal/agent/prompts_wiki_test.go
T
wizardchen a8a3d9e694 feat: Enhance wiki extraction and configuration options
- Introduced extraction granularity settings in the wiki configuration, allowing users to control the level of detail in entity and concept extraction (focused, standard, exhaustive).
- Updated the UI to reflect these new options, including tooltips for better user guidance.
- Refactored the knowledge base editor to support the new extraction granularity feature, ensuring a seamless user experience.
- Improved the backend logic for wiki ingest tasks to utilize the new granularity settings, enhancing the accuracy of extracted content.
- Added tests to validate the new extraction granularity functionality and ensure robust performance across different configurations.
2026-04-22 21:18:32 +08:00

64 lines
1.9 KiB
Go

package agent
import (
"strings"
"testing"
)
func TestWikiGranularityGuidance_RoutesByKey(t *testing.T) {
cases := map[string]string{
"focused": WikiGranularityGuidanceFocused,
"standard": WikiGranularityGuidanceStandard,
"exhaustive": WikiGranularityGuidanceExhaustive,
}
for key, want := range cases {
if got := WikiGranularityGuidance(key); got != want {
t.Errorf("WikiGranularityGuidance(%q) returned unexpected block", key)
_ = got
}
}
}
func TestWikiGranularityGuidance_UnknownDefaultsToStandard(t *testing.T) {
unknowns := []string{"", "FOCUSED", "detailed", "minimal", "full", "unknown"}
for _, k := range unknowns {
if WikiGranularityGuidance(k) != WikiGranularityGuidanceStandard {
t.Errorf("WikiGranularityGuidance(%q) should fall back to STANDARD block", k)
}
}
}
// Sanity check that the three guidance blocks are meaningfully different.
// A regression (e.g. two constants accidentally pointing at the same string)
// would silently disable the user-facing level control.
func TestWikiGranularityGuidance_BlocksAreDistinct(t *testing.T) {
blocks := []string{
WikiGranularityGuidanceFocused,
WikiGranularityGuidanceStandard,
WikiGranularityGuidanceExhaustive,
}
seen := make(map[string]bool, len(blocks))
for _, b := range blocks {
if b == "" {
t.Error("granularity guidance block must not be empty")
continue
}
if seen[b] {
t.Error("granularity guidance blocks must be distinct")
}
seen[b] = true
}
// Each block should name its mode, so the LLM can't silently get the
// wrong guidance without us noticing in review.
if !strings.Contains(WikiGranularityGuidanceFocused, "FOCUSED") {
t.Error("focused block should self-identify")
}
if !strings.Contains(WikiGranularityGuidanceStandard, "STANDARD") {
t.Error("standard block should self-identify")
}
if !strings.Contains(WikiGranularityGuidanceExhaustive, "EXHAUSTIVE") {
t.Error("exhaustive block should self-identify")
}
}