dariotm
November 21, 2023, 5:51pm
1
I am uploading a file using the Python API with the following code:
file = client.files.create(
file=open("speech.py", "rb"),
purpose='assistants'
)
However all my uploads appear as “upload” in the file section. How can I change the displayed name to something more friendly? I tried to use the query_param but with no success. Thank you
_j
November 21, 2023, 8:33pm
2
What is the “file section”?
You can write your own file browser and get the file objects, to present as you wish:
{
"id": "file-abc123",
"object": "file",
"bytes": 120000,
"created_at": 1677610602,
"filename": "salesOverview.pdf",
"purpose": "assistants",
}
There is no other metadata that you can add, except by tracking with your own database.
You could thus make your own “assistants file attacher” interface or such.
You can use a tuple like this:
with open("speech.py", "rb") as fp:
file = client.files.create(
file=("speech.py", fp),
purpose='assistants'
)
After struggling with the same problem, I found the answer by digging through the OpenAI code: openai._types.FileTypes
.
1 Like