@@ -52,12 +52,7 @@ Translate the following input text to English. Segments originally written in En
5252
5353The input text may be in Markdown format. Preserve all original formatting and structure in the output.
5454
55- Return the result in JSON format with the following structure:
56-
57- {
58- "original_text_lang": "x", // "en" if the input was entirely English; otherwise, "non-en"
59- "translated_text": "...translated or mixed result here..."
60- }
55+ Return the result in text format, with no additional explanations or comments.
6156
6257---
6358Text:
@@ -101,26 +96,11 @@ Text:
10196 return "" , errors .New ("no choices in response" )
10297 }
10398
104- // Parse model's JSON reply
105- var modelReply struct {
106- OriginalTextLang string `json:"original_text_lang"`
107- TranslatedText string `json:"translated_text"`
108- }
109-
110- if err := json .Unmarshal ([]byte (res .Choices [0 ].Message .Content ), & modelReply ); err != nil {
111- return "" , errors .New ("failed to parse model JSON response: " + err .Error ())
112- }
113-
114- // Check if the original text was already in English
115- if modelReply .OriginalTextLang == "en" {
116- return "" , errors .New ("all lines are already in English, no translation needed" )
117- }
118-
11999 // Close the response body to avoid resource leaks
120100 err = resp .Body .Close ()
121101 if err != nil {
122102 return "" , errors .New ("failed to close response body: " + err .Error ())
123103 }
124104
125- return modelReply . TranslatedText , nil
105+ return res . Choices [ 0 ]. Message . Content , nil
126106}
0 commit comments