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
All checks were successful
Build and Release / release (push) Successful in 1m27s
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user