Skip to content

examples(SingleStoreDB): migrate notebook to openai>=1.0 client API - #2718

Open
kiwigitops wants to merge 2 commits into
openai:mainfrom
kiwigitops:examples/singlestore-migrate-openai-v1
Open

examples(SingleStoreDB): migrate notebook to openai>=1.0 client API#2718
kiwigitops wants to merge 2 commits into
openai:mainfrom
kiwigitops:examples/singlestore-migrate-openai-v1

Conversation

@kiwigitops

@kiwigitops kiwigitops commented May 19, 2026

Copy link
Copy Markdown

Summary

examples/vector_databases/SingleStoreDB/OpenAI_wikipedia_semantic_search.ipynb still uses the pre-v1 OpenAI Python SDK API (openai.ChatCompletion.create, openai.api_key = ..., response["choices"][0]["message"]["content"]). The pre-v1 API was removed in openai>=1.0.0, so this notebook fails immediately for any user who installs the current SDK:

AttributeError: module 'openai' has no attribute 'ChatCompletion'

This PR migrates the affected cells to the v1+ client API. No behavioral changes — same model (gpt-3.5-turbo), same prompts, same temperature.

Changes

-import openai
+from openai import OpenAI

 EMBEDDING_MODEL = "text-embedding-3-small"
 GPT_MODEL = "gpt-3.5-turbo"
-openai.api_key = 'OPENAI API KEY'
-
-response = openai.ChatCompletion.create(
+# Uses OPENAI_API_KEY from your environment.
+client = OpenAI()
+
+response = client.chat.completions.create(
   model=GPT_MODEL,
   messages=[...]
 )
-print(response['choices'][0]['message']['content'])
+print(response.choices[0].message.content)
 # inside ask()
-    response = openai.ChatCompletion.create(
+    response = client.chat.completions.create(
         model=model, messages=messages, temperature=0
     )
-    response_message = response["choices"][0]["message"]["content"]
+    response_message = response.choices[0].message.content

The embeddings helper used elsewhere in this notebook is already on the v1+ API, so the rest of the flow works as soon as the chat calls are migrated.

Test plan

  • Notebook JSON validates and re-renders cleanly.
  • No remaining openai.ChatCompletion.create, openai.api_key = , or dict-style response[...] access in any code cell.
  • Uses the same model and parameters as before — purely an SDK-surface migration.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c44f4cc8d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread examples/vector_databases/SingleStoreDB/OpenAI_wikipedia_semantic_search.ipynb Outdated

Copy link
Copy Markdown
Author

Quick follow-up on this. I addressed the API key issue after review; if this direction still makes sense, I can refresh it against main since it's showing non-mergeable now.

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