Add instruction fields to knowledge base configuration
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
|
||||
func TestBuildVLMCaptionPrompt(t *testing.T) {
|
||||
t.Run("uses configured language and custom instructions", func(t *testing.T) {
|
||||
got := buildVLMCaptionPrompt(context.Background(), types.VLMConfig{
|
||||
DescriptionLanguage: "English",
|
||||
CustomInstructions: "Focus on alarm codes.",
|
||||
})
|
||||
if !strings.Contains(got, "in English") || !strings.Contains(got, "Focus on alarm codes.") {
|
||||
t.Fatalf("unexpected prompt: %s", got)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("defaults to context language", func(t *testing.T) {
|
||||
ctx := context.WithValue(context.Background(), types.LanguageContextKey, "ko-KR")
|
||||
got := buildVLMCaptionPrompt(ctx, types.VLMConfig{})
|
||||
if !strings.Contains(got, "in Korean") {
|
||||
t.Fatalf("unexpected prompt: %s", got)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user