tender summary response fix
This commit is contained in:
@@ -535,9 +535,10 @@ type AISummaryResponse struct {
|
||||
|
||||
// AISummarizeResponse represents the response for triggering on-demand AI summarization
|
||||
type AISummarizeResponse struct {
|
||||
NoticeID string `json:"notice_id"`
|
||||
Summaries []AIDocumentSummary `json:"summaries"`
|
||||
OverallSummary *string `json:"overall_summary"`
|
||||
ContractFolderID string `json:"contract_folder_id"`
|
||||
NoticePublicationID string `json:"notice_publication_id"`
|
||||
Summaries []AIDocumentSummary `json:"summaries"`
|
||||
OverallSummary *string `json:"overall_summary"`
|
||||
}
|
||||
|
||||
// AIDocumentSummary represents a single document summary from the AI service
|
||||
|
||||
+42
-30
@@ -952,44 +952,45 @@ func (s *tenderService) TriggerAISummarize(ctx context.Context, id string) (*AIS
|
||||
return nil, fmt.Errorf("tender not found")
|
||||
}
|
||||
|
||||
noticeID := t.NoticePublicationID
|
||||
if noticeID == "" {
|
||||
if t.NoticePublicationID == "" {
|
||||
return nil, fmt.Errorf("tender has no notice publication ID")
|
||||
}
|
||||
|
||||
// Build the AI summarizer request
|
||||
reqBody := ai_summarizer.SummarizeRequest{
|
||||
NoticeID: noticeID,
|
||||
DocumentURL: t.DocumentURI,
|
||||
Title: t.Title,
|
||||
Description: t.Description,
|
||||
Country: t.CountryCode,
|
||||
SubmissionDeadline: time.UnixMilli(t.SubmissionDeadline).Format(time.RFC3339),
|
||||
if strings.TrimSpace(t.ContractFolderID) == "" {
|
||||
return nil, fmt.Errorf("tender has no contract folder ID")
|
||||
}
|
||||
|
||||
if t.EstimatedValue > 0 {
|
||||
ev := t.EstimatedValue
|
||||
reqBody.EstimatedValue = &ev
|
||||
}
|
||||
if t.Currency != "" {
|
||||
reqBody.Currency = t.Currency
|
||||
}
|
||||
authorityName := ""
|
||||
if t.BuyerOrganization != nil {
|
||||
reqBody.AuthorityName = t.BuyerOrganization.Name
|
||||
authorityName = t.BuyerOrganization.Name
|
||||
}
|
||||
|
||||
reqBody := ai_summarizer.NewSummarizeRequest(ai_summarizer.SummarizeRequestInput{
|
||||
ContractFolderID: t.ContractFolderID,
|
||||
NoticePublicationID: t.NoticePublicationID,
|
||||
DocumentURL: t.DocumentURI,
|
||||
Title: t.Title,
|
||||
Description: t.Description,
|
||||
Country: t.CountryCode,
|
||||
Currency: t.Currency,
|
||||
SubmissionDeadline: t.SubmissionDeadline,
|
||||
EstimatedValue: t.EstimatedValue,
|
||||
AuthorityName: authorityName,
|
||||
})
|
||||
|
||||
s.logger.Info("Triggering on-demand AI summarization", map[string]interface{}{
|
||||
"tender_id": id,
|
||||
"notice_id": noticeID,
|
||||
"tender_id": id,
|
||||
"contract_folder_id": t.ContractFolderID,
|
||||
"notice_publication_id": t.NoticePublicationID,
|
||||
})
|
||||
|
||||
// Call the AI service
|
||||
resp, err := s.aiSummarizerClient.FetchSummaryOnDemand(ctx, reqBody)
|
||||
if err != nil {
|
||||
s.logger.Error("On-demand AI summarization failed", map[string]interface{}{
|
||||
"tender_id": id,
|
||||
"notice_id": noticeID,
|
||||
"error": err.Error(),
|
||||
"tender_id": id,
|
||||
"contract_folder_id": t.ContractFolderID,
|
||||
"notice_publication_id": t.NoticePublicationID,
|
||||
"error": err.Error(),
|
||||
})
|
||||
return nil, fmt.Errorf("AI summarization request failed: %w", err)
|
||||
}
|
||||
@@ -1007,15 +1008,26 @@ func (s *tenderService) TriggerAISummarize(ctx context.Context, id string) (*AIS
|
||||
}
|
||||
|
||||
s.logger.Info("On-demand AI summarization completed", map[string]interface{}{
|
||||
"tender_id": id,
|
||||
"notice_id": noticeID,
|
||||
"summaries_count": len(summaries),
|
||||
"tender_id": id,
|
||||
"contract_folder_id": t.ContractFolderID,
|
||||
"notice_publication_id": t.NoticePublicationID,
|
||||
"summaries_count": len(summaries),
|
||||
})
|
||||
|
||||
noticePublicationID := resp.ResolvedNoticePublicationID()
|
||||
if noticePublicationID == "" {
|
||||
noticePublicationID = t.NoticePublicationID
|
||||
}
|
||||
contractFolderID := strings.TrimSpace(resp.ContractFolderID)
|
||||
if contractFolderID == "" {
|
||||
contractFolderID = t.ContractFolderID
|
||||
}
|
||||
|
||||
return &AISummarizeResponse{
|
||||
NoticeID: resp.NoticeID,
|
||||
Summaries: summaries,
|
||||
OverallSummary: resp.OverallSummary,
|
||||
ContractFolderID: contractFolderID,
|
||||
NoticePublicationID: noticePublicationID,
|
||||
Summaries: summaries,
|
||||
OverallSummary: resp.OverallSummary,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user