Skip to content

Fix OpenAI translator: use Chat Completions - #75

Merged
SamueleMartini merged 2 commits into
mage-os:mainfrom
Girg-Z:fix/openai-chat-completions
Sep 8, 2026
Merged

SamueleMartini merged 2 commits into
mage-os:mainfrom
Girg-Z:fix/openai-chat-completions

Conversation

@Girg-Z

@Girg-Z Girg-Z commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #74.

The translator called the legacy /v1/completions endpoint first and only fell back to Chat Completions when an exception was thrown. With current models, the legacy endpoint can return a 200 response with unusable content, so the fallback is never triggered and that content gets saved as the translation.

  • Call chat() directly, removing the legacy /v1/completions attempt.
  • Pass the translation instructions as a system message and the source text as the user message.
  • Throw an exception when the returned content is null.

Backwards compatibility: Completion-only models are no longer supported, as they don't support /v1/chat/completions.
These should be base older models with limited capabilities, so they were unlikely to produce reliable translations anyway.

@Girg-Z
Girg-Z requested review from a team, SamueleMartini and dadolun95 as code owners September 7, 2026 12:50
@SamueleMartini

Copy link
Copy Markdown
Collaborator

@Girg-Z Thank you for your contribution. Could you please also update the changelog file and add it to the pull request? I'll approve it as soon as you do.
Thank you very much.

@SamueleMartini
SamueleMartini merged commit b8e7ac5 into mage-os:main Sep 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI translator returns garbled or random output on current models

2 participants