Can we upload file with a message in the assistant API. If yes what is the specific end point for this?
I have created an assistant and trained on specific data now I want the user to upload their CSV with messages so they have information about this CSV file.
Yes you can do this, but what you need to do is upload the file separately, and then mention the file_id in your message call. Something like this:
message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="I can not find in the PDF manual how to turn off this device.",
file_ids=[file.id]
)
The caveat being that the file needs to have been previously uploaded to OpenAI and you got the file.id (but you can create your own wrapper function to do both, upload a file, wait for the id, and then insert that into the message along with the content string)
For uploading the file:
from openai import OpenAI
client = OpenAI()
file = client.files.create(
file=open("myfile.pdf", "rb"),
purpose="assistant"
)