Confirm this is an issue with the Python library and not an underlying OpenAI API
[X] This is an issue with the Python library
Describe the bug
I am getting this Error:
File "/Users/konnoryoung/Documents/projects/contract-ai-poc/.errors/lib/python3.9/site-packages/openai/lib/streaming/_assistants.py", line 943, in accumulate_event
block = current_message_snapshot.content[content_delta.index]
IndexError: list index out of range
Which comes from the try/except block in the "accumulate_event" function:
That wouldn't stop my code from running except that it raises another exception:
File "/Users/konnoryoung/Documents/projects/contract-ai-poc/.errors/lib/python3.9/site-packages/openai/_models.py", line 313, in model_dump
raise ValueError("warnings is only supported in Pydantic v2")
ValueError: warnings is only supported in Pydantic v2
Which comes from the if statement:
if warnings != True:
raise ValueError("warnings is only supported in Pydantic v2")
In the if not PYDANTIC_V2 version of the model_dump method of the BaseModel class in the _model.py file.
To Reproduce
1- Pydantic < 2 (I have v1.9.0)
2- Create an assistant
3- Create a thread
4- Attempt to run an Async Stream (my code is below)
Code snippets
from __future__ import annotations
import asyncio
import openai
client = openai.AsyncOpenAI()
assistant_id= """ GetID OR Create an Assistant """
thread_id= """ GetID OR Create a Thread """
async def main() -> None:
async with client.beta.threads.runs.stream(
thread_id=thread_id,
assistant_id=assistant_id,
) as stream:
async for event in stream:
print()
asyncio.run(main())
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
I am getting this Error:
Which comes from the try/except block in the "accumulate_event" function:
That wouldn't stop my code from running except that it raises another exception:
Which comes from the if statement:
In the
if not PYDANTIC_V2
version of themodel_dump
method of theBaseModel
class in the _model.py file.To Reproduce
1- Pydantic < 2 (I have v1.9.0) 2- Create an assistant 3- Create a thread 4- Attempt to run an Async Stream (my code is below)
Code snippets
OS
masOS
Python version
Python 3.9.6
Library version
openai v1.55.0