-
Notifications
You must be signed in to change notification settings - Fork 88
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
Using message file attachments with assistants #69
Comments
Hello, @dmeyeroc! As also outlined in the Assistants API reference (c.f. Here's a quick snippet walking through (1) step-by-step creation of a thread that has a starting message that includes an attachment; and (2) adding another message with both an attachment and mixed content items. // Content for the message
MessageContent contentForMessage
= MessageContent.FromText("Calculate ANOVA for data points in the attached file.");
// Attachment for the message
MessageCreationAttachment attachmentForCodeInterpreter = new(
fileId: "your-data-points-file-id",
tools: [new CodeInterpreterToolDefinition()]);
// Message for the thread
ThreadInitializationMessage messageForNewThread = new([contentForMessage]);
messageForNewThread.Attachments.Add(attachmentForCodeInterpreter);
// Options for creating the thread
ThreadCreationOptions optionsForNewThread = new()
{
InitialMessages = { messageForNewThread },
};
// Creating the thread
AssistantThread thread = client.CreateThread(optionsForNewThread);
// Adding another message, with everything in one shot
ThreadMessage additionalMessage = client.CreateMessage(
thread,
content:
[
"Also, what's this image and how does it relate to a data plot of this additional attached file?",
MessageContent.FromImageUrl(imageUri),
],
options: new MessageCreationOptions()
{
Attachments =
{
new MessageCreationAttachment("another-file-id", [new CodeInterpreterToolDefinition()]);
},
}); Does that additional |
Thanks for your quick response @trrwilson! Yes, this appears to be exactly what we are looking for. We'll put it through its paces and if I hit any more roadblocks I'll bring it back to this thread to hopefully help educate others. I'd recommend adding this example to those that appear in the readme, as I'm sure others may be looking for it there. Thank you again for your responsiveness and detailed answer. |
Hi, I see MessageContent.FromImageUrl(imageUri), but it requires Uri class instanse I far as I understand I cannot to use data url like that:
but I can do it by Open AI API, is there any way to do it by your library? |
Are user-uploaded attachments supported yet using assistants 2.0?
Our use-case is that a user uploads a file and asks a question about the text content of the file, and the AI model produces a result based on the text content of the file and the user's question.
I've been going through the provided examples and sifting through the code, but I don't see a way of referencing/including uploaded files in an assistant thread message. I only see examples of uploading files to a newly created assistant, or using images as message content, neither of which are what we are trying to do.
The text was updated successfully, but these errors were encountered: