Closed amureki closed 6 months ago
Hey @amureki!
Thanks for reporting this. This was actually a bug in the docs, which have now been fixed. The correct parameter name is tools
. I'm going to close this for now, we appreciate your feedback!
@sdcoffey oh, thanks for the swift resolution. 👍
Hi, I have a similar issue while attaching a file to a message:
message = client.beta.threads.messages.create(
thread_id=thread_id,
role="user",
content=question,
attachments=[
{"file_id":file1_id},
{"tools":[{"type":"code_interpreter"}]}
]
)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\f.stragliotto\Desktop\va question_test\.venv\lib\site-packages\openai\resources\beta\threads\messages.py", line 87, in create
return self._post(
File "C:\Users\f.stragliotto\Desktop\va question_test\.venv\lib\site-packages\openai\_base_client.py", line 1240, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
File "C:\Users\f.stragliotto\Desktop\va question_test\.venv\lib\site-packages\openai\_base_client.py", line 921, in request
return self._request(
File "C:\Users\f.stragliotto\Desktop\va question_test\.venv\lib\site-packages\openai\_base_client.py", line 1020, in _request
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': "Missing required parameter: 'attachments[0].tools'.", 'type': 'invalid_request_error', 'param': 'attachments[0].tools', 'code': 'missing_required_parameter'}}
windows
openai 1.27.0
python 3.10.0
Hi, I have a similar issue while attaching a file to a message:
message = client.beta.threads.messages.create( thread_id=thread_id, role="user", content=question, attachments=[ {"file_id":file1_id}, {"tools":[{"type":"code_interpreter"}]} ] )
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\f.stragliotto\Desktop\va question_test\.venv\lib\site-packages\openai\resources\beta\threads\messages.py", line 87, in create return self._post( File "C:\Users\f.stragliotto\Desktop\va question_test\.venv\lib\site-packages\openai\_base_client.py", line 1240, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) File "C:\Users\f.stragliotto\Desktop\va question_test\.venv\lib\site-packages\openai\_base_client.py", line 921, in request return self._request( File "C:\Users\f.stragliotto\Desktop\va question_test\.venv\lib\site-packages\openai\_base_client.py", line 1020, in _request raise self._make_status_error_from_response(err.response) from None openai.BadRequestError: Error code: 400 - {'error': {'message': "Missing required parameter: 'attachments[0].tools'.", 'type': 'invalid_request_error', 'param': 'attachments[0].tools', 'code': 'missing_required_parameter'}}
Os
windows
Library Version
openai 1.27.0
Python Version
python 3.10.0
Did you ever resolve this issue?, I have a similar issue, as far as I can tell my request is OK.
{
"role":"user",
"content":[
{
"type":"text",
"text":"Hello"
}
],
"attachments":[
{
"file_id":"file-5qRBphw6nYJOcbPElxZWbnOz",
"tools":[
{
"type":"file_search"
}
]
}
]
}
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
Greetings fellows,
A migration guide for assistant file upload suggests using the following format:
However, the API reference shows something else: https://platform.openai.com/docs/api-reference/messages/createMessage#messages-createmessage-attachments
Whenever I am using the version explained in the migration guide, I get the following traceback:
To Reproduce
Code snippets
I think, this is the suspected piece in the Python library that differs:
openai.types.beta.threads.message_create_params.Attachment
It expects
add_to
and not atools
list.OS
macOS
Python version
Python v3.12.1
Library version
openai v1.21.2