Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating OpenAIBackend to openai>=1 (#1707) #1724

Merged
merged 2 commits into from Jan 10, 2024
Merged

Migrating OpenAIBackend to openai>=1 (#1707) #1724

merged 2 commits into from Jan 10, 2024

Conversation

peguerosdc
Copy link
Contributor

This PR changes OpenAIBackend to work with openai>=1 by following OpenAI's migration guide where:

  • openai.Embedding.create() -> client.embeddings.create()

Note that the example in the docs was already correct:

client = openai.OpenAI(api_key="sk-...")
openai_embedder = OpenAIBackend(client, "text-embedding-ada-002")

Fixes #1707

@peguerosdc
Copy link
Contributor Author

Also, I think it would be good to specify the OpenAI version supported by BERTopic in the setup.py like:

openai_packages = [
    "openai>=1,<2"
]

setup(
    extras_require={
        "openai": openai_packages
    }
)

But I didn't do it because I don't know if it would break anything for someone else.

@MaartenGr
Copy link
Owner

Thanks for the PR! One small thing. Could you set the version back to 0.16.0? I am not yet creating an official release for 0.16.1.

@peguerosdc
Copy link
Contributor Author

Done, thanks for the review!

@MaartenGr MaartenGr merged commit e2191f0 into MaartenGr:master Jan 10, 2024
@MaartenGr
Copy link
Owner

Awesome, thanks for your work on this PR!

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.

OpenAI embedding Backend
2 participants