feat: implement RAG-based chatbot service with daily usage rate limiting and background index worker
All checks were successful
Build and Release / release (push) Successful in 1m27s

This commit is contained in:
2026-05-06 10:02:00 +07:00
parent 76c5f55cdd
commit a61cf085ce
13 changed files with 442 additions and 38 deletions

View File

@@ -45,8 +45,18 @@ func (cx *ChatbotController) Chat(c fiber.Ctx) error {
})
}
answer, err := cx.chatbotService.Chat(ctx, dto.ProjectID, dto.Question)
claims := c.Locals("user").(*response.JWTClaims)
answer, err := cx.chatbotService.Chat(ctx, claims.UId, dto.ProjectID, dto.Question)
if err != nil {
// Trả về lỗi 429 (Too Many Requests) nếu hết lượt dùng
if err.Error() == "you have reached your daily limit of 10 questions. Please come back tomorrow" {
return c.Status(fiber.StatusTooManyRequests).JSON(response.CommonResponse{
Status: false,
Message: err.Error(),
})
}
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
Status: false,
Message: err.Error(),