diff --git a/internal/services/chatbotService.go b/internal/services/chatbotService.go index a62c4a0..caa8698 100644 --- a/internal/services/chatbotService.go +++ b/internal/services/chatbotService.go @@ -88,6 +88,7 @@ Recent Chat History: The user said: "%s" Rules: +- You MUST reply in the same language as the user's question (e.g., if the user greets or asks in Vietnamese, reply in Vietnamese). - If it is a greeting (like "hello", "hi", "xin chào"), respond with a friendly greeting and briefly introduce yourself. - If it is a history question, say that you don't have relevant documents to answer. - You MUST wrap your final response inside tags. Example: Hello! @@ -96,6 +97,7 @@ Rules: prompt = fmt.Sprintf(`You are a helpful history assistant. Answer the question using ONLY the provided context. Rules: +- You MUST reply in the same language as the user's question (e.g., if the question is in Vietnamese, reply in Vietnamese). - If the answer is not in the context, say "I don't have enough historical context to answer that." - You MUST wrap your final response inside tags. Example: The capital is... - Be concise and direct. diff --git a/pkg/ai/rag.go b/pkg/ai/rag.go index bab19e6..b09b3ed 100644 --- a/pkg/ai/rag.go +++ b/pkg/ai/rag.go @@ -93,12 +93,12 @@ func (u *RagUtils) EmbedQuery(ctx context.Context, query string) ([]float32, err if err != nil || len(vectors) == 0 { return nil, err } - + vector := vectors[0] if len(vector) > 1536 { vector = vector[:1536] } - + return vector, nil }