Timeout Error When Uploading Large Files to Azure OpenAI Assistant Service
Su Myat Hlaing
150
Reputation points
Hi,
I'm encountering a timeout error when trying to upload large files 260 MB (up to 512MB) to the Azure OpenAI service using the assistantsClient.uploadFile
method. I understand that can upload 512MB 20 files. The error occurs after the upload begins, and the operation fails with the following message:
try {
const fileUploadPromises = files.map(async (file) => {
// Read the content from the uploaded file in binary mode
const fileContent = await fs.promises.readFile(file.path);
// Define the filename for the upload
const filename = Buffer.from(file.originalname, 'latin1').toString('utf8');
console.log("before file upload to assistant..");
// Upload the binary file content using Assistants SDK
const uploadAssistantFile = await assistantsClient.uploadFile(fileContent, "assistants", { filename });
console.log("after upload file to assistant..");
return { fileId: uploadAssistantFile.id, filename: filename };
});
// Wait for all file uploads to complete
const fileIdsWithNames = await Promise.all(fileUploadPromises);
// Extract fileIds and filenames separately
const fileIds = fileIdsWithNames.map(file => file.fileId);
const filenames = fileIdsWithNames.reduce((acc, file) => {
acc[file.fileId] = file.filename;
return acc;
}, {});
// Create an assistant using Assistants SDK
const assistantResponse = await assistantsClient.createAssistant({
model: model,
name: name,
instructions: instructions,
tools: [{ type: "code_interpreter" }],
fileIds: fileIds,
});
console.log("Assistant created:", assistantResponse);
--------------------------------------------------------
Error creating assistant: RestError: The operation was timeout.
{
"name": "RestError",
"code": "Timeout",
"statusCode": 408,
"request": {
"url": "https://..openai.azure.com/openai/files?api-version=2024-02-15-preview",
"headers": {
"accept": "application/json",
"content-type": "multipart/form-data; boundary=----AzSDKFormBoundaryef1d4792-52b5-4075-a08c-f241f7507291",
"accept-encoding": "gzip,deflate",
"user-agent": "azsdk-js-openai-assistants-rest/1.0.0-beta.5 core-rest-pipeline/1.14.0 Node/v16.20.2 OS/(x64-Windows_NT-10.0.22631)",
"x-ms-client-request-id": "2c69947f-f245-42e2-a120-d89479e7864f",
"api-key": "REDACTED",
"content-length": "276437299"
},
"method": "POST",
"timeout": 0,
"disableKeepAlive": false,
"withCredentials": false,
"requestId": "2c69947f-f245-42e2-a120-d89479e7864f",
"allowInsecureConnection": false,
"enableBrowserStreams": true
},
"message": "The operation was timeout."
}
I'm looking for guidance on:
- Whether there is a specific timeout limit imposed by the Azure OpenAI service for file uploads.
- Best practices for handling large file uploads to avoid timeouts.
- Any server-side configurations or SDK options that can help mitigate this issue.
Any advice or insights would be greatly appreciated!
Sign in to answer