feat: implement RAG-based chatbot service with usage limits and history persistence
Build and Release / release (push) Successful in 1m23s
Build and Release / release (push) Successful in 1m23s
This commit is contained in:
@@ -2,7 +2,7 @@ package request
|
|||||||
|
|
||||||
type ChatbotDto struct {
|
type ChatbotDto struct {
|
||||||
ProjectID *string `json:"project_id"`
|
ProjectID *string `json:"project_id"`
|
||||||
Question string `json:"question" validate:"required"`
|
Question string `json:"question" validate:"required,max=500"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetChatbotHistoryDto struct {
|
type GetChatbotHistoryDto struct {
|
||||||
|
|||||||
@@ -86,8 +86,7 @@ User Question:
|
|||||||
Rules:
|
Rules:
|
||||||
- Reply in the same language as the user's question.
|
- 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 is greeting, respond with a friendly greeting and briefly introduce yourself.
|
||||||
- If the user asks a history-related question, respond exactly:
|
- 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.").
|
||||||
<answer>I don't have enough historical context to answer that.</answer>
|
|
||||||
- Do not answer historical questions from memory.
|
- Do not answer historical questions from memory.
|
||||||
- Do not use your own knowledge, assumptions, memory, or external facts.
|
- Do not use your own knowledge, assumptions, memory, or external facts.
|
||||||
- Do not guess, infer, assume, or invent missing information.
|
- 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 infer information that is not explicitly stated in Context.
|
||||||
- Never create names, dates, places, events, causes, results, or explanations that are not 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.
|
- Every factual sentence must be directly supported by Context.
|
||||||
- If Context does not contain enough information to answer, respond exactly:
|
- 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.").
|
||||||
<answer>I don't have enough historical context to answer that.</answer>
|
|
||||||
- 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.
|
- 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 mention document scores.
|
||||||
- Do not cite documents unless the user asks.
|
- Do not cite documents unless the user asks.
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ package constants
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MaxDailyAIUsage = 1000
|
MaxDailyAIUsage = 50
|
||||||
UsageExpiration = 24 * time.Hour
|
UsageExpiration = 24 * time.Hour
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user