I have created an assistant with the new V2 API in a python file.
The original message to the assistant asks for extracting tables from a pdf.
The pdf is directly uploaded in the message by
- Uploading the file
file = client.files.create(file = open(file_path,mode="rb"), purpose = "assistants")
- Attaching the file when creating the message
attachments = [{"file_id": file.id, "tools": [{"type": "file_search"}]}]
The message asks to return these tables as a csv file and asks the assistant to provide the “file id” from the csv file that it will generate.
Here are the “attachment” attribute details from the original message:
attachments=[Attachment(file_id='file-8TrHfQH86DIEx4e9D47Lu0q4', tools=[AttachmentToolAssistantToolsFileSearchTypeOnly(type='file_search')])]
At the end of the run, the assistant answers that the job is done and replies:
The file ID for the CSV file is:
file-8TrHfQH86DIEx4e9D47Lu0q4
. You can download the CSV file using the following link: Download CSV file.
Question:
How are we supposed to access/download this file from code?
Issues:
-
The file id in the assistant’s message is exactly the same file id from the original file uploaded/forwarded/attached to the original message.
-
This is confirmed when trying to actually download this file through a get request, which returns:
Error: 400
{'error': {'message': 'Not allowed to download files of purpose: assistants', 'type': 'invalid_request_error', 'param': None, 'code': None}}
- Inspecting the assistant’s message reveals that there is nothing in the assistant’s “attachments” attribute:
attachments=[]
-
I have seen people trying to process this file through file_id retrieval but there is no file_id reference to this mentioned csv file offered by the assistant that is any different from the file_id of the original pdf file uploaded. There is no other file id mentioned in the entire thread.
-
I have no idea if the link mentioned by the assistant actually exists or how to access it if the file is there:
sandbox:/files/download/file-8TrHfQH86DIEx4e9D47Lu0q4
Due to API’s beta status I am not sure if this download functionality has been developed yet as i can not find any reference in the documentation. Any feedback appreciated.