-
Notifications
You must be signed in to change notification settings - Fork 293
Open
Labels
bugCategory: Something isn't working and appears to be a defect in the client library.Category: Something isn't working and appears to be a defect in the client library.
Description
Describe the bug
My code (below) works for CodeInterpreter attachments, but gives the Unknown parameter: 'attachments[0].tools[0].file_search' error for FileSearch attachments. That should be incredibly easy to reproduce. My assistant is configured with both File Search and Code Interpreter enabled.
public async Task PostChat(
string threadId,
string model,
string? instructions,
bool webSearch,
string prompt,
List<(string FileName, Stream Stream)> fileSearch,
List<(string FileName, Stream Stream)> codeInterpreter)
{
var uploadFileSearchTasks = fileSearch.Select(async attachment => (
File: await _fileClient.UploadFileAsync(attachment.Stream, attachment.FileName, FileUploadPurpose.Assistants),
Tool: new List<ToolDefinition>() { ToolDefinition.CreateFileSearch() }
));
var uploadCodeInterpreterTasks = codeInterpreter.Select(async attachment => (
File: await _fileClient.UploadFileAsync(attachment.Stream, attachment.FileName, FileUploadPurpose.Assistants),
Tool: new List<ToolDefinition>() { ToolDefinition.CreateCodeInterpreter() }
));
var tasks = await Task.WhenAll(uploadFileSearchTasks.Concat(uploadCodeInterpreterTasks));
var attachments = tasks.Select(x => new MessageCreationAttachment(x.File.Value.Id, x.Tool));
var message = await _assistantClient.CreateMessageAsync(
threadId,
MessageRole.User,
new[] {
MessageContent.FromText(prompt.ToString()),
},
new MessageCreationOptions() {
Attachments = new List<MessageCreationAttachment>(attachments),
});
var updates = _assistantClient.CreateRunStreamingAsync(threadId, _assistantId);
}
Steps to reproduce
- Upload a file:
var fileId = await openAIFileClient.UploadFileAsync(stream, fileName FileUploadPurpose.Assistants);
- Create an attachment with the Id of the uploaded file and the FileSearch tool:
var attachment = new MessageCreationAttachment(fileId, new List<ToolDefinition>() { ToolDefinition.CreateFileSearch() });
- Send a message with that attachment:
var message = await _assistantClient.CreateMessageAsync(
threadId,
MessageRole.User,
new[] {
MessageContent.FromText(message),
},
new MessageCreationOptions() {
Attachments = new List<MessageCreationAttachment>(attachments),
});
Code snippets
public async Task PostChat(
string threadId,
string model,
string? instructions,
bool webSearch,
string prompt,
List<(string FileName, Stream Stream)> fileSearch,
List<(string FileName, Stream Stream)> codeInterpreter)
{
var uploadFileSearchTasks = fileSearch.Select(async attachment => (
File: await _fileClient.UploadFileAsync(attachment.Stream, attachment.FileName, FileUploadPurpose.Assistants),
Tool: new List<ToolDefinition>() { ToolDefinition.CreateFileSearch() }
));
var uploadCodeInterpreterTasks = codeInterpreter.Select(async attachment => (
File: await _fileClient.UploadFileAsync(attachment.Stream, attachment.FileName, FileUploadPurpose.Assistants),
Tool: new List<ToolDefinition>() { ToolDefinition.CreateCodeInterpreter() }
));
var tasks = await Task.WhenAll(uploadFileSearchTasks.Concat(uploadCodeInterpreterTasks));
var attachments = tasks.Select(x => new MessageCreationAttachment(x.File.Value.Id, x.Tool));
var message = await _assistantClient.CreateMessageAsync(
threadId,
MessageRole.User,
new[] {
MessageContent.FromText(prompt.ToString()),
},
new MessageCreationOptions() {
Attachments = new List<MessageCreationAttachment>(attachments),
});
var updates = _assistantClient.CreateRunStreamingAsync(threadId, _assistantId);
}
OS
Windows
.NET version
8.0
Library version
2.2.0
Metadata
Metadata
Assignees
Labels
bugCategory: Something isn't working and appears to be a defect in the client library.Category: Something isn't working and appears to be a defect in the client library.