Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.26k stars 4.6k forks source link

C# Assistant: how to display Generated Image and Code #42931

Open nssidhu opened 6 months ago

nssidhu commented 6 months ago

Library name and version

Azure.AI.OpenAI.Assistants 1.0.0-beta.3

Query/Question

I am referring to the example at https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/openai/Azure.AI.OpenAI.Assistants

The line below, which is part of the code below seems to be a bug Console.Write($"<image from ID: {imageFileItem.FileId}");

Here under is the ask. Secondly, i want to display the image i two ways ? 1) Disrectly display image in smaller form factor on the page and provide a link to download that image in full resolution. 2) I want to display the Code that is generated and output of that code(weather actual data or compiler Error).

How can i do that ?

Response<PageableList<ThreadMessage>> afterRunMessagesResponse
    = await client.GetMessagesAsync(thread.Id);
IReadOnlyList<ThreadMessage> messages = afterRunMessagesResponse.Value.Data;

// Note: messages iterate from newest to oldest, with the messages[0] being the most recent
foreach (ThreadMessage threadMessage in messages)
{
    Console.Write($"{threadMessage.CreatedAt:yyyy-MM-dd HH:mm:ss} - {threadMessage.Role,10}: ");
    foreach (MessageContent contentItem in threadMessage.ContentItems)
    {
        if (contentItem is MessageTextContent textItem)
        {
            Console.Write(textItem.Text);
        }
        else if (contentItem is MessageImageFileContent imageFileItem)
        {
            Console.Write($"<image from ID: {imageFileItem.FileId}");
        }
        Console.WriteLine();
    }
}

Environment

Visual Studio 2023, C#, Blazor Server.

github-actions[bot] commented 5 months ago

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

nssidhu commented 5 months ago

@jpalvarezl @trrwilson any updates on this ?

nssidhu commented 5 months ago

Any updates on this ?

aaronsarkissian commented 4 months ago

Any news regarding this?

I can use the https://<your_endpoint>.openai.azure.com/openai/files/<file_id>/content?api-version=2024-02-15-preview endpoint to download it but I can't find any native method to do so.