examples(vector_databases): migrate PolarDB, AnalyticDB, Hologres, redisjson to openai>=1.0 API#2721
Open
kiwigitops wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four more vector-database notebooks in
examples/vector_databases/still call the pre-v1 OpenAI Python SDK (openai.Embedding.create(...),openai.api_key = ..., dict-styleresponse["data"][0]["embedding"]). The pre-v1 module-level API was removed inopenai>=1.0.0(November 2023), so these notebooks fail immediately on the current SDK with:This PR migrates all four to the v1+
OpenAI()client API. No model or parameter changes — pure SDK-surface fixes.Notebooks touched
examples/vector_databases/PolarDB/Getting_started_with_PolarDB_and_OpenAI.ipynbexamples/vector_databases/analyticdb/Getting_started_with_AnalyticDB_and_OpenAI.ipynbexamples/vector_databases/hologres/Getting_started_with_Hologres_and_OpenAI.ipynbexamples/vector_databases/redis/redisjson/redisjson.ipynbPer-notebook changes
For PolarDB / AnalyticDB / Hologres (same shape):
For redis/redisjson —
clientis already used for the Redis connection, so the OpenAI client is namedopenai_clientto avoid the collision:Test plan
openai.Embedding.create,openai.api_key,["data"][0]["embedding"], or other pre-v1 patterns in any code cellRelated
Follow-up to the same migration pattern from: