Uploaded file name becomes 'file' unconditionally

I realized that ‘openai.File.create’ unconditionally changes a file name as ‘file’ yesterday (4/13/2022). Here is the line in my app.

fileInfo = openai.File.create(file=open("\gpt3\uploading.json"), purpose=“answers”)

A filename properties in fileInfo structure contains ‘file’ instead of ‘uploading.json’. I am sure that an uploaded file name was a file name without folder name. The last upload was probably 10 days ago. I confirmed the last upload uses an actual file name instead of ‘file’. How can I set an actual file name to an uploaded file name instead of ‘file’.

Does anyone now what’s going on? Any help will be appreciated.

I’m getting this as well, could anyone from OpenAI please help?

I updated a file like this:
response = openai.File.create(file=open(“train.jsonl”, “rb”), purpose=‘fine-tune’)

and when I list file, the filename always called “file”, this will cause the later uploads overwrite the previous one, and eventually I can only have 1 file uploaded.

{
  "bytes": 209,
  "created_at": 1676821064,
  "filename": "file",
  "id": "file-j6lzVv4YmAd3brhflWerxyBt",
  "object": "file",
  "purpose": "fine-tune",
  "status": "uploaded",
  "status_details": null
}

Could anyone from OpenAI look into this?

Thanks.

@dwang @yamaguchi.hiro if you’re still wondering about this, I found a solution: pass user_provided_filename=‘your-file-name’ when you call openai.File.create()

1 Like

Nice solution! Could you please provide the source of this parameter? Thanks.

@lawrencepbr , I can’t remember where I picked it up, but I do remember that I could never find mention of it in any of the official docs. Seems to work just fine though.

It’s based on their python SDK on GitHub.

I’m getting this as well, could anyone from OpenAI please help?

I updated a file like this:
response = openai.File.create(file=open(“train.jsonl”, “rb”), purpose=‘fine-tune’)

and when I list file, the filename always called “file”, this will cause the later uploads overwrite the previous one, and eventually I can only have 1 file uploaded.

{
  "bytes": 209,
  "created_at": 1676821064,
  "filename": "file",
  "id": "file-j6lzVv4YmAd3brhflWerxyBt",
  "object": "file",
  "purpose": "fine-tune",
  "status": "uploaded",
  "status_details": null
}

Could anyone from OpenAI look into this?

Thanks.

Did you ever get a solution for this? I’m running into the same problem

Based on their python SDK on GitHub, you need to add one argument called “user_provided_filename”, for example:

res = await openai.File.acreate(
            file=file.getvalue(),
            purpose="fine-tune",
            user_provided_filename=file.name)

I use this method to upload file:

response = openai.File.create(file=open("test.jsonl", "rb"), purpose="fine-tune")

I can’t give the name of the uploaded file and it will always be “file”. Earlier I used the OpenAI API CLI and it seems it used the name of my local file as filename in the uploaded list.

| File ID                       | Object   |   Bytes | Created             | File name                        | Purpose   |
|-------------------------------|----------|---------|---------------------|----------------------------------|-----------|
| file-okR5ToAuB9bUIID81CH7QtX2 | file     |     205 | 2023-06-11 15:29:55 | file                             | fine-tune |
| file-DUQxtcx241NelpHnDxqMiywM | file     |     205 | 2023-06-11 15:58:58 | file                             | fine-tune |

Can I somehow define the name of the uploaded file via the Python openai.File.create() call as well?

Based on their python SDK on GitHub, you need to add one argument called “user_provided_filename”, for example:

res = await openai.File.acreate(
            file=file.getvalue(),
            purpose="fine-tune",
            user_provided_filename=file.name)
1 Like

As far as I can see this argument does not exist for uploading Assistant files (either for the Assistant or Thread? Anyone else had any luck with this?

3 Likes

This OpenAI GitHub issue solved my problem for new API version: Allow filename to be passed as a parameter into `files.create` · Issue #871 · openai/openai-python · GitHub

1 Like

Oh that is great - I’m going to try that right away! Thanks for sharing!