translation body update

This commit is contained in:
Mazyar
2026-05-13 14:50:37 +03:30
parent ba9e7483ad
commit 584992f0b6
3 changed files with 33 additions and 18 deletions
+8
View File
@@ -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(),
@@ -99,6 +105,8 @@ func (w *TranslationWorker) translateTender(t *tender.Tender) {
resp, err := w.AIClient.FetchTranslationOnDemand(context.Background(), ai_summarizer.TranslateRequest{
NoticeID: t.NoticePublicationID,
ContractFolderID: t.ContractFolderID,
NoticePublicationID: t.NoticePublicationID,
Title: t.Title,
Description: t.Description,
Language: w.TargetLanguage,
+5
View File
@@ -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{
@@ -1059,6 +1062,8 @@ func (s *tenderService) TriggerAITranslate(ctx context.Context, id, language str
resp, err := s.aiSummarizerClient.FetchTranslationOnDemand(ctx, ai_summarizer.TranslateRequest{
NoticeID: t.NoticePublicationID,
ContractFolderID: t.ContractFolderID,
NoticePublicationID: t.NoticePublicationID,
Title: t.Title,
Description: t.Description,
Language: targetLanguage,
+3 -1
View File
@@ -42,7 +42,9 @@ 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
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