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.25k stars 4.58k forks source link

[OpenAI] [Scenario] Add abstractions for chat conversations #42538

Open joseharriaga opened 6 months ago

joseharriaga commented 6 months ago

From @trrwilson:

ChatClient client = GetTestClient();

ChatConversation conversation = new(client)
{
    InitialMessages =
    [
        ChatRequestMessage.CreateSystemMessage(
            "You are a culinary expert who speaks like a stereotypical caricature of a New Yorker."),
    ],
    Functions = new ChatFunctions(typeof(CulinaryDatabaseTools)),
};

ChatCompletion chatCompletion = conversation.CompleteChat("What are some of the best pizza toppings?");
chatCompletion = conversation.CompleteChat("Which of those are vegetarian-friendly?");
chatCompletion = conversation.CompleteChat("Are any of those spicy?");

conversation.Reset();
chatCompletion = conversation.CompleteChat("What's the best way to cook a pumpkin pie?");
pallavit commented 6 months ago

What benefit does ChatConversation give us over ChatCompletion? Is the usecase purely enabling support for post processing - so function calls?