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

Azure OpenAI - Upload file with purpose set to "batch" #628

Open
agiordimaina opened this issue Sep 17, 2024 · 0 comments
Open

Azure OpenAI - Upload file with purpose set to "batch" #628

agiordimaina opened this issue Sep 17, 2024 · 0 comments

Comments

@agiordimaina
Copy link

Describe the bug
Uploading a file with the purpose set to “batch” using Azure OpenAI is failing.

Code

var openAiService = new OpenAIService(new OpenAiOptions()
{
    ApiKey = "{apiKey}",
    ProviderType = ProviderType.Azure,
    DefaultModelId = Models.Gpt_4o_mini,
    ResourceName = "{resourceName}",
    ApiVersion = "2024-07-01-preview",
    DeploymentId = "{deploymentId}"
});

FileUploadResponse result = await openAiFileService.Files.UploadFile("batch", fileContent, "test.jsonl");

Result
The upload fails with the error: “Resource not found”.

Additional context
Using the "2024-07-01-preview" version, you can now upload files with "purpose" set to "batch".
https://learn.microsoft.com/en-us/rest/api/azureopenai/files/upload?view=rest-azureopenai-2024-07-01-preview&tabs=HTTP#purpose

The current URI format used by the library is:
https://{resourceName}.openai.azure.com/openai/deployments/{deploymentId}/files?api-version=2024-07-01-preview

The correct URI format for Azure OpenAI when using purpose set to "batch" should be:
https://{resourceName}.openai.azure.com/openai/files?api-version=2024-07-01-preview

Another issue related to uploading files is that when using ByteArrayContent to upload the file, the header is not being set. This results in the following error:
The file has no or an empty content type specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant