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

Async calls using new SDK by OpenAI #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rafayaar
Copy link

Issue / Bug
Current implementation of OpenAIMultiClient is according to older version of OpenAI.
For async calls acreate function was used to do asynchronous calls.
Example from OpenAI repo:

import openai

completion = openai.ChatCompletion.acreate(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hello world"}])

When executing this MultiClient it says to migrate the code accordingly, and gives a lot of errors.
Either we can fix this by explicitly downloading earlier version of openai which is openai==0.28 or the migration I have done.

Fix

OpenAI has introduced AsyncOpenAI class through which we can handle this case
Example from OpenAI repo:

from openai import AsyncOpenAI

client = AsyncOpenAI()
completion = await client.chat.completions.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hello world"}])

Calls are relatively different from previous SDK. New SDK has a lot of changes.

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