Skip to content

Using message file attachments with assistants #69

@dmeyeroc

Description

@dmeyeroc

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.

...
RunCreationOptions runCreationOptions = new RunCreationOptions()
{
    InstructionsOverride = "Sample role",
    ModelOverride = "gpt-4o"
}

runCreationOptions.ToolsOverride.Add(new FileSearchToolDefinition());

ThreadCreationOptions threadCreationOptions = new()
{
    InitialMessages =
    {
        new ThreadInitializationMessage(new List<MessageContent>
        {
            "Hello, assistant! Please tell me something about the contents of this file",
            //MessageContent.FromImageFileId(pictureOfAppleFile.Id), // don't need this
            //MessageContent.FromImageUrl(linkToPictureOfOrange), // don't need this
            // Is there a different way to get it to reference a file that is not an image?
        })
    },
};

ThreadRun threadRun = await _assistantsClient.CreateThreadAndRunAsync(_assistantId, threadCreationOptions, runCreationOptions)
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionCategory: The issue is seeking information about the library or its usage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions