Files
ai-agent/internal/ai/rag/retrieve_test.go
T
mlogclub 5d7c10aeab refactor: rename agent widget references to AI agent for consistency
- Updated runtime configuration to use __CS_AI_AGENT_WIDGET_CONFIG__ instead of __CS_AGENT_WIDGET_CONFIG__.
- Changed message types in support host bridge from "cs-agent" to "cs-ai-agent".
- Minified SDK script updated to reflect new AI agent naming conventions.
- Adjusted scrollbar styles in main.scss to use .cs-ai-agent-scrollbar instead of .cs-agent-scrollbar.
2026-05-30 21:19:36 +08:00

50 lines
1.3 KiB
Go

package rag
import (
"testing"
"cs-ai-agent/internal/models"
)
func TestResolveKnowledgeBaseSearchOptionsUsesKnowledgeBaseDefaults(t *testing.T) {
topK, scoreThreshold := resolveKnowledgeBaseSearchOptions(RetrieveRequest{}, &models.KnowledgeBase{
DefaultTopK: 6,
DefaultScoreThreshold: 0.42,
})
if topK != 6 {
t.Fatalf("expected topK 6, got %d", topK)
}
if scoreThreshold != float32(0.42) {
t.Fatalf("expected score threshold 0.42, got %v", scoreThreshold)
}
}
func TestResolveKnowledgeBaseSearchOptionsRequestOverridesKnowledgeBaseDefaults(t *testing.T) {
topK, scoreThreshold := resolveKnowledgeBaseSearchOptions(RetrieveRequest{
TopK: 9,
ScoreThreshold: 0.55,
}, &models.KnowledgeBase{
DefaultTopK: 6,
DefaultScoreThreshold: 0.42,
})
if topK != 9 {
t.Fatalf("expected request topK 9, got %d", topK)
}
if scoreThreshold != float32(0.55) {
t.Fatalf("expected request score threshold 0.55, got %v", scoreThreshold)
}
}
func TestResolveKnowledgeBaseSearchOptionsUsesSystemDefaults(t *testing.T) {
topK, scoreThreshold := resolveKnowledgeBaseSearchOptions(RetrieveRequest{}, nil)
if topK != 8 {
t.Fatalf("expected fallback topK 8, got %d", topK)
}
if scoreThreshold != float32(0.3) {
t.Fatalf("expected fallback score threshold 0.3, got %v", scoreThreshold)
}
}