-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
Hi there,
I noticed a small typo in the example code provided in the README file. The code snippet uses asyncio.run(main()) but is missing the import statement for asyncio. This could cause confusion for users running the example as it will result in a NameError: name 'asyncio' is not defined.
To Reproduce
Here's the updated code with the necessary import:
from openai import AsyncOpenAI
import asyncio # Add this import
client = AsyncOpenAI()
async def main():
stream = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Say this is a test"}],
stream=True,
)
async for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
asyncio.run(main())Code snippets
No response
OS
Python version
Library version
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working