openai-python
openai-python copied to clipboard
Threads messages list misinterprets the block type
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
When getting the messages list for the last response in a run, I sometimes get the following content
content=[ImageFileContentBlock(image_file=None, type='text', text={'value': '...'}, (...) ) ]
instead of
content=[TextContentBlock(text=Text(annotations=[], value="..."), (...))]
The ImageFileContentBlock comes when asking for data from files and the TextContentBlock when asking generic questions like "how are you?". Even if it is the default behavior (not sure why image file of type text), these structures are not structured in the same way, the first one has the 'text' field a dictionary and the second one has a Text object
To Reproduce
- create a message (client.beta.threads.messages.create)
- create a run and wait for response (client.beta.threads.runs.create_and_poll)
- get response (client.beta.threads.messages.list)
Code snippets
messages = client.beta.threads.messages.list(
thread_id=thread_id,
run_id=run_id,
timeout=requests_timeout
)
OS
Linux
Python version
Python v3.11.4
Library version
openai v1.23.1