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

Getting 404 error when trying to upload a large file in Assistants API #273

Open
gmantri opened this issue Oct 29, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@gmantri
Copy link

gmantri commented Oct 29, 2024

Service

Azure OpenAI

Describe the bug

I am trying to upload a large file (approximately 110MB) in Assistants API (I am using Azure OpenAI, FWIW). I am trying to upload it by splitting it in chunks. However, I am getting the error in the very first request when I try to create an upload (so that I can get an upload id).

Here's my code:

var client = new Azure.AI.OpenAI.AzureOpenAIClient(new Uri(azureOpenAiEndpoint), new DefaultAzureCredential());
var uploadData = $"{{purpose: 'assistants',filename:'azure-storage-blobs.pdf',bytes:{bytesRemaining},mime_type:'application/pdf'}}";
var createUploadResult = fileClient.CreateUpload(BinaryContent.Create(new MemoryStream(Encoding.UTF8.GetBytes(uploadData))));

I am getting a 404 error on the last line. When I see the request details, I noticed that it is trying to make a Post request at https://<my-azure-open-ai-service-name>.openai.azure.com/uploads and that is failing with 404 error. Here's the complete error stack trace:

System.ClientModel.ClientResultException
  HResult=0x80131500
  Message=HTTP 404 (: 404)

Resource not found
  Source=OpenAI
  StackTrace:
   at OpenAI.ClientPipelineExtensions.ProcessMessage(ClientPipeline pipeline, PipelineMessage message, RequestOptions options) in /_/src/Custom/Internal/ClientPipelineExtensions.cs:line 47
   at OpenAI.Files.InternalUploadsClient.CreateUpload(BinaryContent content, RequestOptions options) in /_/src/Generated/InternalUploadsClient.cs:line 56
   at OpenAI.Files.OpenAIFileClient.CreateUpload(BinaryContent content, RequestOptions options) in /_/src/Custom/Files/OpenAIFileClient.Protocol.cs:line 241
   at AssistantsAPIDemo.Program.Main(String[] args) in C:\Users\CP00DCY\source\repos\AssistantsAPIDemo\Program.cs:line 48

Uploading small files in single request works perfectly fine.

Also, why there are no properly typed objects as input and output for uploading file in chunks? For uploading files in chunks, I noticed that the input is always BinaryContent and the output is ClientResult. That would mean that I will need to manually parse the response that is returned by the API.

Steps to reproduce

Please see above

Code snippets

var client = new Azure.AI.OpenAI.AzureOpenAIClient(new Uri(azureOpenAiEndpoint), new DefaultAzureCredential());
var uploadData = $"{{purpose: 'assistants',filename:'azure-storage-blobs.pdf',bytes:{bytesRemaining},mime_type:'application/pdf'}}";
var createUploadResult = fileClient.CreateUpload(BinaryContent.Create(new MemoryStream(Encoding.UTF8.GetBytes(uploadData))));

OS

Windows

.NET version

8.0

Library version

Azure.AI.OpenAI (2.1.0-beta.1)

@gmantri gmantri added the bug Something isn't working label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant