feat: implement RAG-based chatbot service with usage limits and history persistence
Build and Release / release (push) Successful in 1m23s

This commit is contained in:
2026-06-05 21:20:23 +07:00
parent 32ade66c6c
commit f55bc6c0e6
3 changed files with 4 additions and 6 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ package request
type ChatbotDto struct {
ProjectID *string `json:"project_id"`
Question string `json:"question" validate:"required"`
Question string `json:"question" validate:"required,max=500"`
}
type GetChatbotHistoryDto struct {
+2 -4
View File
@@ -86,8 +86,7 @@ User Question:
Rules:
- Reply in the same language as the user's question.
- If the user is greeting, respond with a friendly greeting and briefly introduce yourself.
- If the user asks a history-related question, respond exactly:
<answer>I don't have enough historical context to answer that.</answer>
- If the user asks a history-related question, respond in the same language as the user's question, stating that you don't have enough historical context to answer that (for example, in Vietnamese: "Tôi không có đủ dữ liệu lịch sử để trả lời câu hỏi này.").
- Do not answer historical questions from memory.
- Do not use your own knowledge, assumptions, memory, or external facts.
- Do not guess, infer, assume, or invent missing information.
@@ -110,8 +109,7 @@ Rules:
- Never infer information that is not explicitly stated in Context.
- Never create names, dates, places, events, causes, results, or explanations that are not in Context.
- Every factual sentence must be directly supported by Context.
- If Context does not contain enough information to answer, respond exactly:
<answer>I don't have enough historical context to answer that.</answer>
- If Context does not contain enough information to answer, respond in the same language as the user's question, stating that you don't have enough historical context to answer that (for example, in Vietnamese: "Tôi không có đủ dữ liệu lịch sử để trả lời câu hỏi này.").
- If Context only partially answers the question, answer only the supported part and clearly say the remaining information is not available in the provided context.
- Do not mention document scores.
- Do not cite documents unless the user asks.
+1 -1
View File
@@ -3,6 +3,6 @@ package constants
import "time"
const (
MaxDailyAIUsage = 1000
MaxDailyAIUsage = 50
UsageExpiration = 24 * time.Hour
)