-
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
Add configuration for OpenAI prompt #533
Add configuration for OpenAI prompt #533
Conversation
3dd43c7
to
8151b07
Compare
templates/config/i18n-tasks.yml
Outdated
@@ -116,6 +116,17 @@ search: | |||
# # OpenAI | |||
# openai_api_key: "sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |||
# # openai_model: "gpt-3.5-turbo" # see https://platform.openai.com/docs/models | |||
# # openai_system_prompt: # may contain `%{from}` and `%{to}`, which will be replaced by source and target locale codes, respectively, using `Kernel.format` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The settings in this file are formatted so that uncommenting turns them into valid options.
Please move the comment above the line and add the appropriate multiline string sigil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just changed it as I think you requested 👍
I tried to make it consistent with what was done for Deepl configuration, for both mandatory configuration lines, optional (commented) configuration lines and plain old comments (with plain old English).
I used a folded style indicator (>
) with a "stripping" block chomping indicator (-
) to explicitly indicate the multiline field and how it will be processed (resulting in a >-
marker): it seems to me it was the more logical processing method to apply, but I'm happy to change it if you prefer another one.
I hope that's what you expected.
On a side note, though, I'm pretty sure the previous implementation was still valid YAML when uncommented (despite the end-of-line comment and the lack of explicit multiline indicator 🤷):
YAML.safe_load(<<~YAML)
openai_system_prompt: # may contain `%{from}` and `%{to}`, which will be replaced by source and target locale codes, respectively (using `Kernel.format`)
You are a professional translator that translates content from the %{from} locale
to the %{to} locale in an i18n locale array.
The array has a structured format and contains multiple strings. Your task is to translate
each of these strings and create a new array with the translated strings.
HTML markups (enclosed in < and > characters) must not be changed under any circumstance.
Variables (starting with %%{ and ending with }) must not be changed under any circumstance.
Keep in mind the context of all the strings for a more accurate translation.
YAML
# => {"openai_system_prompt"=>
# "You are a professional translator that translates content from the %{from} locale to the %{to} locale in an i18n locale array.\nThe array has a structured format and contains multiple strings. Your task is to translate each of these strings and create a new array with the translated strings.\nHTML markups (enclosed in < and > characters) must not be changed under any circumstance. Variables (starting with %%{ and ending with }) must not be changed under any circumstance.\nKeep in mind the context of all the strings for a more accurate translation."}
YAML is such a pain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, YAML is gnarly. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to you for all the work on this gem 🙏 💜
The default prompt now includes instructions to **never** translate HTML tags (e.g. `<strong>`) nor Ruby I18n variables (e.g. `%{count}`). This commit also makes the system prompt passed to OpenAI configurable directly from `i18n-tasks.yml`.
8151b07
to
c425870
Compare
The default prompt now includes instructions to never translate HTML tags (e.g.
<strong>
) nor Ruby I18n variables (e.g.%{count}
).This PR also makes the system prompt passed to OpenAI configurable directly from
i18n-tasks.yml
.Incidentally, it also fixes a Rubocop offense.
This is a followup of #532.