Skip to content

Make chatgpt_request compatible with OpenAI 2.x#12

Merged
sderev merged 2 commits into
mainfrom
openai2-migration
Apr 14, 2026
Merged

Make chatgpt_request compatible with OpenAI 2.x#12
sderev merged 2 commits into
mainfrom
openai2-migration

Conversation

@sderev

@sderev sderev commented Apr 12, 2026

Copy link
Copy Markdown
Owner

What changed

  • Updated vocabmaster/gpt_integration.py so chatgpt_request uses the OpenAI Responses 2.x public interfaces: client.responses.stream(...) for streaming and client.responses.create(...) for non-streaming.
  • Removed reliance on private SDK error helpers and kept streaming TSV filtering behavior.
  • Added regression coverage in tests/test_gpt_integration_sdk_boundary.py for streaming/non-streaming behavior, streamed delta handling, fallback to final output text, and public RateLimitError propagation.
  • Widened the openai dependency constraint in pyproject.toml and refreshed uv.lock accordingly.
  • Added changelog fragment changelog.d/openai-2x-compatibility.md.

Why

  • The previous integration path depended on OpenAI SDK 1.x behavior and private internals that are not stable in 2.x.
  • This keeps the existing vocabmaster flow compatible with OpenAI 2.x while preserving current output behavior.

How to test

  • Automated:
  • Run gate from the repository root.
  • Functional/manual:
  • Set OPENAI_API_KEY (or ~/.config/lmt/key.env) with a valid key.
  • Run vocabmaster pairs add and create a test pair.
  • Run vocabmaster add <word> for one or more words in that pair.
  • Run vocabmaster translate and verify TSV output still shows original_word, translations/definition field, and a single example sentence per row.
  • Re-run vocabmaster translate with enough words to observe streamed output and confirm no SDK compatibility error is raised.

Risk/comp notes

  • Main compatibility risk is SDK event-shape drift on future OpenAI releases; tests pin current expected public event usage.
  • Streaming path now depends on response.output_text.delta events; when absent, code falls back to final_response.output_text.

Changelog fragment

  • yes — user-visible compatibility fix documented in changelog.d/openai-2x-compatibility.md.

The boundary regex in `.ci/changelog-notes` stopped at `## `
headers and `<a id=` anchors, but not at the trailing scriv
marker.  Once scriv emits `<!-- scriv-end-here -->`, the extractor
would silently include it in release notes.

Port the fix from shellgenius so the extractor also stops at
`<!-- scriv-end-here -->`.

Co-authored-by: AI <ai@sderev.com>
@sderev

sderev commented Apr 13, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

* switch streaming requests to `client.responses.stream()` and drop the private status-error helper
* add direct SDK-boundary tests for streaming, fallback, and error propagation
* widen supported `openai` versions to `<3.0` and refresh `uv.lock`

Co-authored-by: AI <ai@sderev.com>
@sderev sderev force-pushed the openai2-migration branch from be45df7 to f71f774 Compare April 14, 2026 20:26
@sderev sderev merged commit f71f774 into main Apr 14, 2026
@sderev sderev deleted the openai2-migration branch April 14, 2026 20:26
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.

1 participant