Skip to content

Patchwork: migrate openai to the new API - #1

Closed
ABHISAARPANDEY wants to merge 1 commit into
mainfrom
patchwork/openai-0c84ac
Closed

Patchwork: migrate openai to the new API#1
ABHISAARPANDEY wants to merge 1 commit into
mainfrom
patchwork/openai-0c84ac

Conversation

@ABHISAARPANDEY

@ABHISAARPANDEY ABHISAARPANDEY commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Patchwork rewrote the openai call sites broken by an upstream API change — the actual code, not just a version bump.

Verification

✅ Verified — the migrated code compiles (npm run build passed in a clean checkout).

What changed

  • Configuration — The Configuration class has been removed; construct the client directly using the default export. (removal)
  • OpenAIApi — The OpenAIApi class has been removed; construct the client directly using the default export. (removal)
  • openai.createChatCompletionopenai.chat.completions.create — The createChatCompletion method has moved under the chat.completions namespace. (move)
  • openai.createCompletionopenai.completions.create — The createCompletion method has moved under the completions namespace. (move)
  • openai.createEmbeddingopenai.embeddings.create — The createEmbedding method has moved under the embeddings namespace. (move)
  • response.data — Methods now return the JSON response body directly; remove the .data accessor. (response shape)

Files rewritten

  • client.ts — Updated to use the default export for OpenAI client construction, moved createCompletion to completions.create, and removed .data accessor from response.

Dependency: Bump openai ^3.2.1 → ^4.0.0

🤖 Opened by Patchwork — self-maintaining APIs.

Summary by CodeRabbit

  • Bug Fixes
    • Updated OpenAI integration to maintain compatibility with the latest SDK.
    • Improved handling of generated completion responses.

- The Configuration class has been removed; construct the client directly using the default export.
- The OpenAIApi class has been removed; construct the client directly using the default export.
- The createChatCompletion method has moved under the chat.completions namespace.
- The createCompletion method has moved under the completions namespace.
- The createEmbedding method has moved under the embeddings namespace.
- Methods now return the JSON response body directly; remove the .data accessor.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ff6a259-41de-42e4-a3ce-9fe5eb3b92fe

📥 Commits

Reviewing files that changed from the base of the PR and between dfbe1eb and 6292671.

📒 Files selected for processing (2)
  • client.ts
  • package.json

📝 Walkthrough

Walkthrough

The OpenAI dependency is upgraded to version 4, and client.ts adopts the new OpenAI client construction, completion request method, and response shape.

Changes

OpenAI SDK migration

Layer / File(s) Summary
Update OpenAI client integration
package.json, client.ts
Upgrades openai from ^3.2.1 to ^4.0.0, initializes OpenAI with the API key, and switches completion requests and response extraction to the v4 interface.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: migrating the OpenAI integration to the new API.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch patchwork/openai-0c84ac

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ABHISAARPANDEY
ABHISAARPANDEY deleted the patchwork/openai-0c84ac branch July 27, 2026 16:57
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