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(),

View File

@@ -78,7 +78,7 @@ func (s *submissionController) CreateSubmission(c fiber.Ctx) error {
// @Security BearerAuth
// @Router /submissions/{id}/status [patch]
func (s *submissionController) UpdateSubmissionStatus(c fiber.Ctx) error {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 300*time.Second)
defer cancel()
id := c.Params("id")
uid := c.Locals("uid").(string)