I want to use openai embeddings for bertopic emmbeding parameter
but i cannot use because of version changes
my code
Bertopic Documentation for openai embeddings

I want to use openai embeddings for bertopic emmbeding parameter
but i cannot use because of version changes
my code
Bertopic Documentation for openai embeddings

It looks like you might be using an older pip version of openai.
Have you tried upgrading it?
pip3 install openai --upgrade
Welcome to the amazing world of OpenAI API libs!
Welcome to the amazing world of python!
It says in the error message: consider running pip install openai==0.28.1
check your version then with pip show openai
you may run into the problem again you had in the first post, but it’s possible that that was an issue with the 1.0 versions, so you might not.
Yes, as you suggested, I installed and tried version 0.28.1, but the result remains the same; it still gives an error.
unfortunately, I can’t reproduce it - it works on my machine with this configuration
I don’t know if openai was actually a function at some point so it was just openai(api_key...) but I’m not 100% certain.
Ideally, I’d suggest you step into the openai import and see what you’re actually importing, but if you’re not experienced enough for that, and until someone comes along that remembers how the call went, we can try this:
I see you have jupyter
can you try doing a minimal attempt at getting the client to work?
import os
import openai
client = openai.OpenAI(
# This is the default and can be omitted
api_key=os.environ.get("OPENAI_API_KEY"),
)
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
)
and if that doesn’t work, the output from
print(openai)
and
print(dir(openai))
I’m restricted to phone-only access here.
This is an active GitHub issue.
Temporary solution is to downgrade as mentioned. Then you need to initialize openai using the old builder way.
import openai
openai.api_key = "bop"
If you’re feeling helpful you can migrate the library instead