Problemas con el valor de retorno del detector de configuración regional

We’ve encountered two different issues on two different forums, where the content localization started to translate posts into their original language (and worse, weirdly messing up the content or adding “this post is already in English!”).

Digging into this, it turned out that the locale detector was not receiving a pure language code from the LLM.

Instead, it was wrapped in markdown ``` (copying the relevant parts from the log only for readability

"delta":{"content":"```"}
"delta":{"content":"en```"},

or it had surrounding quotes, probably confused by the prompt which says Output: "en"

"delta":{"content":"\""}
"delta":{"content":"en\""}

Changing the last line of the prompt to Your response must be a language code, and nothing else. Do not wrap your response in markdown. helped but I guess LanguageDetector.detect should clean up the answer a bit (maybe allowing only AZaz and - ?) before using it.

1 me gusta