Giter VIP home page Giter VIP logo

Comments (2)

github-actions avatar github-actions commented on September 27, 2024

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @ralph-msft @trrwilson.

from azure-sdk-for-net.

trrwilson avatar trrwilson commented on September 27, 2024

Thank you for getting in touch, @raysuelzer!

You're absolutely right that this use of attachments with Assistants v2 and the new library is missing sample coverage at the moment; I'll ensure we get a work item filed to have the changes better documented.

As a direct answer, you can extend the pattern shown in this test code by using the Attachments property of MessageCreationOptions.

Here's a rough adaptation of the test to demonstrate:

[Test]
public void MessageWithAttachmentWorks()
{
    AssistantClient client = GetTestClient();

    FileClient fileClient = GetTestClient<FileClient>(TestScenario.Files);
    OpenAIFileInfo numbersFile = fileClient.UploadFile(
        BinaryData.FromString("""
        15
        20
        22
        12
        20
        """).ToStream(),
        "text/plain",
        FileUploadPurpose.Assistants);
    Validate(numbersFile);

    Assistant assistant = client.CreateAssistant(
        "gpt-4o",
        new AssistantCreationOptions()
        {
            Tools = { new CodeInterpreterToolDefinition() },
            ToolResources = new()
            {
                CodeInterpreter = new()
                {
                        FileIds = [numbersFile.Id],
                }
            }
        });

    AssistantThread thread = client.CreateThread();
    Validate(thread);

    ThreadMessage message = client.CreateMessage(
        thread.Id,
        MessageRole.User,
        content:
        [
            MessageContent.FromText("What's the standard deviation of the numbers in the attached file?"),
        ],
        new MessageCreationOptions()
        {
            Attachments =
            {
                new MessageCreationAttachment(
                    numbersFile.Id,
                    tools: [ new CodeInterpreterToolDefinition() ]),
            }
        });
    Validate(message);

    foreach (StreamingUpdate chunk in client.CreateRunStreaming(thread.Id, assistant.Id))
    {
        if (chunk is MessageContentUpdate contentUpdate)
        {
            Console.Write(contentUpdate.Text);
        }
    }
}

Which yields:

    It appears that the file contains a single column of numbers. To calculate the standard deviation of these numbers, we can proceed with the computation.The standard deviation of the numbers in the file is approximately \(4.43\).

from azure-sdk-for-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.