Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.25k stars 4.58k forks source link

[BUG] UploadFileAsync(Stream, OpenAIFilePurpose, String, CancellationToken) #44929

Open saket223 opened 1 month ago

saket223 commented 1 month ago

Type of issue

Code doesn't work No matter how I try to provide the filename, it rejects with a 400 error

Description

var file = await _assistantsClient.UploadFileAsync(uploads.First().Content.GetStream(), OpenAIFilePurpose.Assistants,uploads.First().Content.FileName);

[13:39:22.970 ERR] 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 } }

var file = await _assistantsClient.UploadFileAsync("/pathToFile/abc.pdf", OpenAIFilePurpose.Assistants);

Status: 400 (Bad Request)

Content: { "error": { "message": "Additional properties are not allowed ('filename' was unexpected)", "type": "invalid_request_error", "param": null, "code": null } }

Page URL

https://learn.microsoft.com/en-us/dotnet/api/azure.ai.openai.assistants.assistantsclient.uploadfileasync?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

1baff563-233f-3513-2052-29313fd91076

Article author

@azure-sdk

Metadata

github-actions[bot] commented 1 month ago

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

trrwilson commented 1 month ago

Hello, @saket223! I apologize for those documents being behind; as mentioned on the project page, Assistants has converged into the new v2.x combined Azure.AI.OpenAI library, which in turn builds on OpenAI's official OpenAI library. Can you please try using the latest Azure.AI.OpenAI for your scenario? You can find examples both in the project README as well as in the tests; OpenAI's examples are also fully applicable, including this one: https://github.com/openai/openai-dotnet?tab=readme-ov-file#how-to-use-streaming-and-gpt-4o-vision-with-assistants (just be sure to use AzureOpenAIClient!)

saket223 commented 1 month ago

Hi @trrwilson I tried implementing this v2 version of assistants, but some part of it does not exist in the azure openAI library.

PageCollection messagePages = assistantClient.GetMessages(threadRun.ThreadId, new MessageCollectionOptions() { Order = ListOrder.OldestFirst }); IEnumerable messages = messagePages.GetAllValues();

This part of code is not working.. The GetAllValues() does not exist