Implement AI analysis trigger endpoint and refactor related components
- Added a new endpoint to trigger on-demand agentic analysis for tenders via the AI service. - Introduced `TriggerAIAnalyze` method in the `TenderHandler` to handle requests and responses for AI analysis. - Updated the `tenderService` to include `TriggerAIAnalyze` method, which validates input and interacts with the AI summarizer client. - Enhanced the `AIAnalyzeResponse` and `AIAnalyzeDocument` structures to support the new analysis feature. - Refactored the `DocumentSummarizationWorker` and `TranslationWorker` to remove deprecated MinIO dependencies, streamlining the AI service interactions. This update improves the functionality of the tender management system by allowing users to trigger AI analysis on-demand, enhancing the overall user experience and system capabilities.
This commit is contained in:
@@ -398,7 +398,7 @@ func (h *TenderHandler) GetPublicTenderDetails(c echo.Context) error {
|
||||
|
||||
// GetDocumentSummaries retrieves document summaries for a tender
|
||||
// @Summary Get document summaries for a tender
|
||||
// @Description Retrieve AI-generated summaries of documents for a specific tender
|
||||
// @Description Retrieve per-document AI summaries from the AI service MinIO storage for a specific tender
|
||||
// @Tags Tenders
|
||||
// @Produce json
|
||||
// @Param id path string true "Tender ID"
|
||||
@@ -595,6 +595,36 @@ func (h *TenderHandler) TriggerAISummarize(c echo.Context) error {
|
||||
return response.Success(c, result, "AI summarization completed successfully")
|
||||
}
|
||||
|
||||
// TriggerAIAnalyze triggers on-demand agentic analysis for a tender
|
||||
// @Summary Trigger AI analysis
|
||||
// @Description Trigger on-demand agentic document analysis for a tender via the external AI service
|
||||
// @Tags Admin-Tenders
|
||||
// @Produce json
|
||||
// @Param id path string true "Tender ID"
|
||||
// @Success 200 {object} response.APIResponse{data=AIAnalyzeResponse}
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 404 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /admin/v1/tenders/{id}/ai-analyze [post]
|
||||
// @Security BearerAuth
|
||||
func (h *TenderHandler) TriggerAIAnalyze(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
if id == "" {
|
||||
return response.BadRequest(c, "Tender ID is required", "ID parameter cannot be empty")
|
||||
}
|
||||
|
||||
result, err := h.service.TriggerAIAnalyze(c.Request().Context(), id)
|
||||
if err != nil {
|
||||
h.logger.Error("Failed to trigger AI analysis", map[string]interface{}{
|
||||
"tender_id": id,
|
||||
"error": err.Error(),
|
||||
})
|
||||
return response.InternalServerError(c, err.Error())
|
||||
}
|
||||
|
||||
return response.Success(c, result, "AI analysis completed successfully")
|
||||
}
|
||||
|
||||
// TriggerAITranslate triggers on-demand AI translation for a tender
|
||||
// @Summary Trigger AI translation
|
||||
// @Description Trigger on-demand AI translation for tender title and description (cached in MinIO by the AI service)
|
||||
|
||||
Reference in New Issue
Block a user