Hey there.
Recently started working with Assistants.
Message handler looks like this:
client.beta.threads.messages.create(
thread_id=thread_id,
role="user",
content=message,
)
But after some time decided to add also image handler such that user uploads the image and Assistant understands.
Scanning API 2-3 hours could not find the solution.
So I would like to discuss it with you.
How it can be fixed:
if file_path:
file = client.files.create(
file=open(file_path, "rb"),
purpose="vision"
)
client.beta.threads.messages.create(
thread_id=thread_id,
role="user",
content=message,
attachments=[
{"file_id": file.id, "tools": [{"type": "file_search"}]}
],
)
Hope this will be solved and be helpful for others.