Skip to content

Migrate to openai >=1.0.0,<2 - #175

Open
ehsandaya1-blip wants to merge 1 commit into
smol-ai:mainfrom
ehsandaya1-blip:relay/openai-1.0.0
Open

ehsandaya1-blip wants to merge 1 commit into
smol-ai:mainfrom
ehsandaya1-blip:relay/openai-1.0.0

Conversation

@ehsandaya1-blip

Copy link
Copy Markdown

This updates the project's use of openai from <1.0.0 to >=1.0.0,<2, following the provider's migration guide (openai/openai-python#742).

What changed

  • openai.ChatCompletion.createclient.chat.completions.create (7 sites): Resource classes moved under the client with snake_case, plural resource names.
  • openai.api_key / openai.api_base / openai.organization (module globals)openai.OpenAI(api_key=..., base_url=..., organization=...) (5 sites): Module-level configuration is replaced by an explicit client object.
  • openai.ChatCompletion.acreateAsyncOpenAI().chat.completions.create (awaited) (1 site): Async variants (acreate) are removed; use AsyncOpenAI client and await the same method name.

Files touched: 6.

How this was produced

Deterministic rewrites from a machine-readable MigrationSpec for this upgrade, then a review pass on the semantic residue; every changed file was parsed and checked with pyflakes for new undefined names before this PR was prepared. No behaviour beyond the migration was touched: no reformatting, no import reordering, no unrelated code.

Happy to adjust anything — if the project deliberately pins the old major version, say so and I will close this.

Notes for reviewers

  • smol_dev/prompts.py calls file_paths.from_response(completion) from the third-party openai_function_call package, which parsed openai 0.x dict responses; that dependency needs its own update for 1.x (not part of this change).
  • The old import openai lines are kept next to the new client import (they are unused now in six files; removing them was out of the migration's scope).

- **openai.ChatCompletion.create** → `client.chat.completions.create` (7 sites): Resource classes moved under the client with snake_case, plural resource names.
- **openai.api_key / openai.api_base / openai.organization (module globals)** → `openai.OpenAI(api_key=..., base_url=..., organization=...)` (5 sites): Module-level configuration is replaced by an explicit client object.
- **openai.ChatCompletion.acreate** → `AsyncOpenAI().chat.completions.create (awaited)` (1 site): Async variants (`acreate`) are removed; use `AsyncOpenAI` client and await the same method name.
Files touched: 6.
Deterministic rewrites from a machine-readable MigrationSpec for this upgrade, then a review pass on the semantic residue; every changed file was parsed and checked with pyflakes for new undefined names before this PR was prepared. No behaviour beyond the migration was touched: no reformatting, no import reordering, no unrelated code.
Happy to adjust anything — if the project deliberately pins the old major version, say so and I will close this.
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