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
I see this error after an async streaming call to the completion end-point:
an error occurred during closing of asynchronous generator <async_generator object aiohttp_session at 0x1029de110>
asyncgen: <async_generator object aiohttp_session at 0x1029de110>
RuntimeError: aclose(): asynchronous generator is already running
To Reproduce
Run the code below. The completion_text is printed and below that the error above is shown.
Code snippets
importasynciofromtypesimportAsyncGeneratorTypefromdotenvimportload_dotenvimportosimportopenaiload_dotenv()
openai.api_key=os.getenv("OPENAI_API_KEY")
asyncdeftest_completion_async_stream():
completion=awaitopenai.Completion.acreate(
model="text-davinci-003",
prompt="Hello!",
stream=True,
)
# Assert response bodyassertisinstance(completion, AsyncGeneratorType)
collected_chunks= []
completion_text=''# iterate through the stream, if it breaks, the test failedasyncforchunkincompletion:
collected_chunks.append(chunk)
finish_reason=chunk['choices'][0]['finish_reason'] # type: ignoreiffinish_reasonisnotNone:
breakchunk_text=chunk['choices'][0]['text'] # type: ignorecompletion_text+=chunk_text# append the textprint(completion_text)
if__name__=="__main__":
asyncio.run(test_completion_async_stream())
OS
macOS 13.4 (22F66)
Python version
3.11.4
Library version
0.27.8
The text was updated successfully, but these errors were encountered:
Describe the bug
I see this error after an async streaming call to the completion end-point:
To Reproduce
Run the code below. The
completion_text
is printed and below that the error above is shown.Code snippets
OS
macOS 13.4 (22F66)
Python version
3.11.4
Library version
0.27.8
The text was updated successfully, but these errors were encountered: