examples(elasticsearch): migrate notebook to openai>=1.0 client API#2719
Open
kiwigitops wants to merge 1 commit into
Open
examples(elasticsearch): migrate notebook to openai>=1.0 client API#2719kiwigitops wants to merge 1 commit into
kiwigitops wants to merge 1 commit into
Conversation
3 tasks
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
examples/vector_databases/elasticsearch/elasticsearch-retrieval-augmented-generation.ipynbstill uses the pre-v1 OpenAI Python SDK (openai.api_key = ...,openai.Embedding.create(...),openai.ChatCompletion.create(...), dict-styleresponse["data"][0]["embedding"]). The pre-v1 API was removed inopenai>=1.0.0(Nov 2023), so the notebook now fails withAttributeError: module 'openai' has no attribute 'Embedding'on the current SDK.This PR migrates the affected cells. The Elasticsearch
clientvariable is left alone — the new OpenAI client is namedopenai_clientto avoid collision.Changes
The downstream usage
summary.choices/choice.message.contentalready works on the v1+ response shape, so only the create call needed swapping.Test plan
openai.ChatCompletion,openai.Embedding,openai.api_key, or dict-style["data"][0]["embedding"]access in code cells