-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Openai translation - base_translator.rb:92:in `next': iteration reached an end (StopIteration) #525
Comments
Can you supply a minimal example to recreate it? How does the config file look? |
To test it, I've created a new rails app (6.1.7.6), ruby (2.7.2), added ruby-openai and i18n-tasks. Copied a 300+ line en.yml file to the project and asked to translate it with: It fails with the original error. I comment-out all but 10 translatable lines in en.yml... it works. Did some debugging in Openai code... it seems that the response from Openai sometimes removes duplicate translations, especially in the case of using the <<: syntax, where blocks are reused in multiple places. Input to Openai was x strings, but sometimes it only returned x-y strings, which is causing the error. Example YAML:
@jmeiss Have you had this issue? |
I never faced this issue, probably because we don't use the <<: syntax in our i18n files, sorry :/ |
@jmeiss Thank you. I realize that the syntax is not really preserved in doin translations through this gem anyway, so probably a good choice 😅 A possible fix, that I got working for this kind of scenario, is changing the Openai model to "gpt-4", which keeps returning correct number of values no matter my yml setup... I am just not skilled enough to make a pull request to make the model a variable in i18n-tasks.yml instead of a hardcoded value in openai_translator.rb 😕 |
Unfortunately |
@davidwessman Yeah, that was my conclusion as well. Will have to work around it, cause the times when I get this gem to work, it is pure magic 🥳 |
I'll keep it in mind if I work again on that code. I want to be able to let the user add a custom prompt to improve it based on your scenario. For instance, I noticed this morning that ChatGPT doesn't keep the pronouns. Example: "Vous" in French is sometimes translated as "tu" in Spanish which is not as formal. |
Would be great if you could try to make a PR to improve the error message, otherwise I think we should close this. |
Hi
When trying to execute the command "i18n-tasks translate-missing sv --from=en --backend=openai" (after realizing there was no support for dotenv variables), I keep getting the error below. I am running the latest commit with ref "249f0dd61b4e2a07befad96bed8e1f89b7527d3e", but also tried the one with the "openai" commit. Same problem.
How can I help debug this?
The text was updated successfully, but these errors were encountered: