Append JSON instructions to OpenAI system prompt#615
Append JSON instructions to OpenAI system prompt#615davidwessman merged 4 commits intoglebm:mainfrom
Conversation
…sponse_format json_object
|
@navidemad can you fix the linting error? (Add an ignore for the too long line). @glebm do you have any input on how we should handle these instructions? I have not used OpenAI for any translation. |
|
@davidwessman I fixed the linting error as requested |
|
I don't do ruby at all anymore but this PR makes sense to me in principle. |
|
@jaredmoody @dankimio @yshmarov you have recently done Open AI-issues on the repo, does this change look good to you as well? 🙂 |
|
@jaredmoody yes, this looks good. not sure if there's a need for a separate |
|
@dankimio I made it that way because if someone sets the :openai_system_prompt option—for example, to create a custom prompt—but forgets to include this JSON part, it will also fail. This way, it will be appended automatically, preventing this issue. |
|
We do something very similar to this in our prompt, so LGTM. As a future enhancement though, it would be nice to request JSON from the API by passing https://github.com/alexrudall/ruby-openai?tab=readme-ov-file#json-mode |
https://github.com/glebm/i18n-tasks/blob/main/lib/i18n/tasks/translators/openai_translator.rb#L101 |
|
Ah, great, I missed when that was added last month. |
In order to fix response_format json_object introduced in the following commit: a0e2fef