Closed Freddeb closed 5 months ago
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.
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'
I'm also having issues. It seems the Files API has been updated; no longer accepts a filepath
but the actual file
.
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.
@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.
@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.
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 @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.
Hi Roger thanks for the quick reply.
I did look through your code but I am not subscribing to azure. I have two questions.
Looking at your usage example, the line
Files localFile = new Files(AzureEndpointDefault, AzureKeyDefault);
I know the azurekeydefault can be replaced by my openAI key, not sure what to use for the AzureEndpointDefault??
My main question though is how this links to var fileUploadresponse = await client.UploadFileAsync(stream, OpenAIFilePurpose.Assistants, null, token);
are you saying that your resVal string is the same result as fileUploadresponse.Value.Id??
If so I think I get it.
Kind regards John
From: Roger D @.> Sent: Tuesday, May 28, 2024 8:12 PM To: Azure/azure-sdk-for-net @.> Cc: John Evans @.>; Mention @.> Subject: Re: [Azure/azure-sdk-for-net] AssistantsClient.UploadFile "message": "Additional properties are not allowed ('filename' was unexpected) (Issue #43953)
Hi @Freddebhttps://github.com/Freddeb @rogerdarylhttps://github.com/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 @JohnTranstelhttps://github.com/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.
— Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-sdk-for-net/issues/43953#issuecomment-2135937184, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEDZRJ3KZOVUL6DXZOVAX2LZETJJHAVCNFSM6AAAAABHO4MI5WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVHEZTOMJYGQ. You are receiving this because you were mentioned.Message ID: @.**@.>>
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.
Hi Roger, Thanks so much for all of this, I have it working just fine now.
Needed a few tweaks around endpoints, and headers and other parameters so I also learned a little more 😊
John
From: Roger D @.> Sent: Tuesday, May 28, 2024 8:49 PM To: Azure/azure-sdk-for-net @.> Cc: John Evans @.>; Mention @.> Subject: Re: [Azure/azure-sdk-for-net] AssistantsClient.UploadFile "message": "Additional properties are not allowed ('filename' was unexpected) (Issue #43953)
Hi @JohnTranstelhttps://github.com/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.
— Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-sdk-for-net/issues/43953#issuecomment-2135992676, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEDZRJ6EIZLC63SBVZNGE23ZETNSNAVCNFSM6AAAAABHO4MI5WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVHE4TENRXGY. You are receiving this because you were mentioned.Message ID: @.**@.>>
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