Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssistantsClient.UploadFile "message": "Additional properties are not allowed ('filename' was unexpected) #43953

Closed
Freddeb opened this issue May 9, 2024 · 10 comments
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.

Comments

@Freddeb
Copy link

Freddeb commented May 9, 2024

Type of issue

Code doesn't work

Description

When the method UploadFile is called with the parameters: stream, OpenAIFilePurpose.Assistants and a filename then the following exception is raised (request status:400) with the message:
"message": "Additional properties are not allowed ('filename' was unexpected)

My parameter filename contains a string with a filename with a pdf extension.
I use the library to connect directly on the API of OpenAI (not through Azure OpenAI).

Page URL

https://learn.microsoft.com/en-us/dotnet/api/azure.ai.openai.assistants.assistantsclient.uploadfile?view=azure-dotnet-preview

Content source URL

https://github.com/Azure/azure-docs-sdk-dotnet/blob/master/xml/Azure.AI.OpenAI.Assistants/AssistantsClient.xml

Document Version Independent Id

22aa7835-27b0-0f7e-3907-678244873658

Article author

@azure-sdk

Metadata

  • ID: 1b6c6901-94c5-93d9-ce74-46aa7f35713a
  • Service: azure
@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team. labels May 9, 2024
Copy link

github-actions bot commented May 9, 2024

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.

@rogerdaryl
Copy link

I am getting the same, but I am using the library to connect to Azure OpenAI. Using Azure.AI.OpenAI.Assistants 1.0.0-beta.4
Response<OpenAIFile> uploadAssistantFileResponse = await _client.UploadFileAsync(tempFile, OpenAIFilePurpose.Assistants);

Azure.RequestFailedException: 'Additional properties are not allowed ('filename' was unexpected)
Status: 400 (Bad Request)
Content:
{
"error": {
"message": "Additional properties are not allowed ('filename' was unexpected)",
"type": "invalid_request_error",
"param": null,
"code": null
}
}

Headers:
Access-Control-Allow-Origin: REDACTED
x-ms-middleware-request-id: REDACTED
X-Content-Type-Options: REDACTED
X-Request-ID: REDACTED
apim-request-id: REDACTED
Strict-Transport-Security: REDACTED
x-ms-client-request-id: efc0e964-d49f-43b4-9a01-2f99a415fc3d
x-ms-region: REDACTED
Date: Mon, 13 May 2024 22:17:22 GMT
Content-Length: 178
Content-Type: application/json'

@georgegkonis
Copy link

I'm also having issues. It seems the Files API has been updated; no longer accepts a filepath but the actual file.

@Freddeb
Copy link
Author

Freddeb commented May 14, 2024

I created a MemoryStream and I filled it up with the binary content of the PDF, i call the method UploadFile and this time i let the default parameter value (null) for the filename but It does not work neither.

@rogerdaryl
Copy link

@Freddeb I have put together an alternate wrapper that you can use to upload files (using restsharp and the /openai/files endpoints)
https://github.com/ViceVersaLtd/viceversa.ai.openai.files

It got me around the bug, so thought I would share.

@Freddeb
Copy link
Author

Freddeb commented May 15, 2024

@rogerdaryl
Hi Roger, thank you to share this code sample.

I call the OpenAI library from a chatbot developed for Microsoft Teams (Microsoft Bot Framework 4).
The file is first uploaded (in the conversation prompt and saved on the user business OneDrive) then the bot application receives a converstation activity with the file information. I load the file from a http request in a MemoryStream.

I will adapt your code and use the function RestRequest.AddFile (3rd overload) that supports a stream as parameter.

Thank you.

@JohnTranstel
Copy link

Hi @Freddeb @rogerdaryl I am struggling with the same problem.
I now have my file as a stream and it is not accepted. I already have my file uploaded server side, and can easily convert it into byte[] or MemoryStream, but it is the 2 lines

var client = new AssistantsClient(apiKey);
var fileUploadresponse = await client.UploadFileAsync(stream, OpenAIFilePurpose.Assistants, null, token);

where I still have a problem.
(The fourth parameter is a new Cancellation token, it makes no difference). The error is that the file is not one of the list of possible file types.
Am I still to use UploadFileAsync or should I be using a different client.xxx function?

Any help appreciated
Thanks

@rogerdaryl
Copy link

Hi @Freddeb @rogerdaryl I am struggling with the same problem. I now have my file as a stream and it is not accepted. I already have my file uploaded server side, and can easily convert it into byte[] or MemoryStream, but it is the 2 lines

var client = new AssistantsClient(apiKey); var fileUploadresponse = await client.UploadFileAsync(stream, OpenAIFilePurpose.Assistants, null, token);

where I still have a problem. (The fourth parameter is a new Cancellation token, it makes no difference). The error is that the file is not one of the list of possible file types. Am I still to use UploadFileAsync or should I be using a different client.xxx function?

Any help appreciated Thanks

Hi @JohnTranstel,

I wrote my own function to get around the bug.
Details are here.
https://github.com/ViceVersaLtd/viceversa.ai.openai.files

Let me know if you need more info than that.

@JohnTranstel
Copy link

JohnTranstel commented May 28, 2024 via email

@rogerdaryl
Copy link

Hi @JohnTranstel,

The "AzureKeys" variables in my code can be swapped for OpenAI values (the Endpoints are defined the same)

And yes, my ResVal is the same as fileUploadresponse.Value.Id. Which is all you need to associate it with the Assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention This issue needs attention from Azure service team or SDK team OpenAI question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants