You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run your async code, I get:
Error: await can't be used outside of a function.
When I enclose the async code within an async function, I get:
TypeError: object Stream can't be used in 'await' expression
The text was updated successfully, but these errors were encountered:
importopenaiimportasyncioasyncdefgenerate_cheesecake_names():
asyncforchunkinawaitopenai.ChatCompletion.acreate(
model="gpt-3.5-turbo",
messages=[{
"role": "user",
"content": "Generate a list of 20 great names for sentient cheesecakes that teach SQL"
}],
stream=True,
):
content=chunk["choices"][0].get("delta", {}).get("content")
ifcontentisnotNone:
print(content, end='')
asyncio.run(generate_cheesecake_names())
When I run your async code, I get:
Error: await can't be used outside of a function.
When I enclose the async code within an async function, I get:
TypeError: object Stream can't be used in 'await' expression
The text was updated successfully, but these errors were encountered: