translation body update
This commit is contained in:
@@ -88,6 +88,12 @@ func (w *TranslationWorker) translateTender(t *tender.Tender) {
|
||||
if t.NoticePublicationID == "" {
|
||||
return
|
||||
}
|
||||
if strings.TrimSpace(t.ContractFolderID) == "" {
|
||||
w.Logger.Debug("Skipping tender translation: missing contract_folder_id", map[string]interface{}{
|
||||
"tender_id": t.ID.Hex(),
|
||||
})
|
||||
return
|
||||
}
|
||||
if existing, ok := t.Translations[w.TargetLanguage]; ok && strings.TrimSpace(existing.Title) != "" {
|
||||
w.Logger.Debug("Skipping tender translation because target language already exists", map[string]interface{}{
|
||||
"tender_id": t.ID.Hex(),
|
||||
@@ -98,16 +104,18 @@ func (w *TranslationWorker) translateTender(t *tender.Tender) {
|
||||
}
|
||||
|
||||
resp, err := w.AIClient.FetchTranslationOnDemand(context.Background(), ai_summarizer.TranslateRequest{
|
||||
NoticeID: t.NoticePublicationID,
|
||||
Title: t.Title,
|
||||
Description: t.Description,
|
||||
Language: w.TargetLanguage,
|
||||
NoticeID: t.NoticePublicationID,
|
||||
ContractFolderID: t.ContractFolderID,
|
||||
NoticePublicationID: t.NoticePublicationID,
|
||||
Title: t.Title,
|
||||
Description: t.Description,
|
||||
Language: w.TargetLanguage,
|
||||
})
|
||||
if err != nil {
|
||||
w.Logger.Error("Failed to translate tender", map[string]interface{}{
|
||||
"tender_id": t.ID.Hex(),
|
||||
"notice_id": t.NoticePublicationID,
|
||||
"target_language": w.TargetLanguage,
|
||||
"tender_id": t.ID.Hex(),
|
||||
"notice_id": t.NoticePublicationID,
|
||||
"target_language": w.TargetLanguage,
|
||||
"translation_error": err.Error(),
|
||||
})
|
||||
return
|
||||
@@ -133,9 +141,9 @@ func (w *TranslationWorker) translateTender(t *tender.Tender) {
|
||||
|
||||
if err := w.TenderRepo.Update(context.Background(), t); err != nil {
|
||||
w.Logger.Error("Failed to persist translated tender", map[string]interface{}{
|
||||
"tender_id": t.ID.Hex(),
|
||||
"notice_id": t.NoticePublicationID,
|
||||
"target_language": w.TargetLanguage,
|
||||
"tender_id": t.ID.Hex(),
|
||||
"notice_id": t.NoticePublicationID,
|
||||
"target_language": w.TargetLanguage,
|
||||
"persistence_error": err.Error(),
|
||||
})
|
||||
return
|
||||
|
||||
@@ -1047,6 +1047,9 @@ func (s *tenderService) TriggerAITranslate(ctx context.Context, id, language str
|
||||
if t.NoticePublicationID == "" {
|
||||
return nil, fmt.Errorf("tender has no notice publication ID")
|
||||
}
|
||||
if strings.TrimSpace(t.ContractFolderID) == "" {
|
||||
return nil, fmt.Errorf("tender has no contract folder ID")
|
||||
}
|
||||
|
||||
if tr, ok := t.Translations[targetLanguage]; ok {
|
||||
return &AITranslateResponse{
|
||||
@@ -1058,10 +1061,12 @@ func (s *tenderService) TriggerAITranslate(ctx context.Context, id, language str
|
||||
}
|
||||
|
||||
resp, err := s.aiSummarizerClient.FetchTranslationOnDemand(ctx, ai_summarizer.TranslateRequest{
|
||||
NoticeID: t.NoticePublicationID,
|
||||
Title: t.Title,
|
||||
Description: t.Description,
|
||||
Language: targetLanguage,
|
||||
NoticeID: t.NoticePublicationID,
|
||||
ContractFolderID: t.ContractFolderID,
|
||||
NoticePublicationID: t.NoticePublicationID,
|
||||
Title: t.Title,
|
||||
Description: t.Description,
|
||||
Language: targetLanguage,
|
||||
})
|
||||
if err != nil {
|
||||
s.logger.Error("On-demand AI translation failed", map[string]interface{}{
|
||||
|
||||
@@ -42,10 +42,12 @@ type StoredDocument struct {
|
||||
// TranslateRequest represents the request payload sent to the AI service
|
||||
// POST /ai/translate endpoint.
|
||||
type TranslateRequest struct {
|
||||
NoticeID string `json:"notice_id"` // required
|
||||
Title string `json:"title"` // required
|
||||
Description string `json:"description"` // required
|
||||
Language string `json:"language,omitempty"` // optional target language override
|
||||
NoticeID string `json:"notice_id"` // required (TED-style notice key)
|
||||
ContractFolderID string `json:"contract_folder_id"` // required by AI service (procedure / MinIO prefix)
|
||||
NoticePublicationID string `json:"notice_publication_id"` // required by AI service
|
||||
Title string `json:"title"` // required
|
||||
Description string `json:"description"` // required
|
||||
Language string `json:"language,omitempty"` // optional target language override
|
||||
}
|
||||
|
||||
// TranslateResponse represents the response from the AI translation API.
|
||||
|
||||
Reference in New Issue
Block a user