diff --git a/docs/ai/quickstarts/build-chat-app.md b/docs/ai/quickstarts/build-chat-app.md index 23cee375bda01..fa15f67858db4 100644 --- a/docs/ai/quickstarts/build-chat-app.md +++ b/docs/ai/quickstarts/build-chat-app.md @@ -1,6 +1,6 @@ --- title: Quickstart - Build an AI chat app with .NET -description: Create a simple AI powered chat app using Semantic Kernel SDK for .NET and the OpenAI or Azure OpenAI SDKs +description: Create a simple AI powered chat app using Microsoft.Extensions.AI and the OpenAI or Azure OpenAI SDKs ms.date: 04/09/2025 ms.topic: quickstart ms.custom: devx-track-dotnet, devx-track-dotnet-ai @@ -31,8 +31,6 @@ In this quickstart, you learn how to create a conversational .NET console chat a [!INCLUDE [semantic-kernel](includes/semantic-kernel.md)] -[!INCLUDE [clone-sample-repo](includes/clone-sample-repo.md)] - ## Create the app Complete the following steps to create a .NET console app to connect to an AI model. @@ -104,13 +102,13 @@ Complete the following steps to create a .NET console app to connect to an AI mo ## Add the app code -The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Microsoft.Extensions.AI/) package to send and receive requests to the AI model and is designed to provide users with information about hiking trails. +This app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Microsoft.Extensions.AI/) package to send and receive requests to the AI model. The app provides users with information about hiking trails. -1. In the **Program.cs** file, add the following code to connect and authenticate to the AI model. +1. In the `Program.cs` file, add the following code to connect and authenticate to the AI model. :::zone target="docs" pivot="azure-openai" - :::code language="csharp" source="snippets/build-chat-app/azure-openai/program.cs" range="1-12"::: + :::code language="csharp" source="snippets/build-chat-app/azure-openai/program.cs" id="GetChatClient"::: > [!NOTE] > searches for authentication credentials from your local tooling. If you aren't using the `azd` template to provision the Azure OpenAI resource, you'll need to assign the `Azure AI Developer` role to the account you used to sign in to Visual Studio or the Azure CLI. For more information, see [Authenticate to Azure AI services with .NET](../azure-ai-services-authentication.md). @@ -119,17 +117,17 @@ The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Micr :::zone target="docs" pivot="openai" - :::code language="csharp" source="snippets/build-chat-app/openai/program.cs" range="1-11"::: + :::code language="csharp" source="snippets/build-chat-app/openai/program.cs" id="GetChatClient"::: :::zone-end 1. Create a system prompt to provide the AI model with initial role context and instructions about hiking recommendations: - :::code language="csharp" source="snippets/build-chat-app/openai/program.cs" range="13-30"::: + :::code language="csharp" source="snippets/build-chat-app/openai/program.cs" id="FirstMessage"::: 1. Create a conversational loop that accepts an input prompt from the user, sends the prompt to the model, and prints the response completion: - :::code language="csharp" source="snippets/build-chat-app/openai/program.cs" range="32-51"::: + :::code language="csharp" source="snippets/build-chat-app/openai/program.cs" id="ChatLoop"::: 1. Use the `dotnet run` command to run the app: @@ -143,11 +141,10 @@ The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Micr ## Clean up resources -When you no longer need the sample application or resources, remove the corresponding deployment and all resources. +If you no longer need them, delete the Azure OpenAI resource and GPT-4 model deployment. -```azdeveloper -azd down -``` +1. In the [Azure Portal](https://aka.ms/azureportal), navigate to the Azure OpenAI resource. +1. Select the Azure OpenAI resource, and then select **Delete**. :::zone-end diff --git a/docs/ai/quickstarts/build-vector-search-app.md b/docs/ai/quickstarts/build-vector-search-app.md index 70a469a21be4b..39c9823f066f4 100644 --- a/docs/ai/quickstarts/build-vector-search-app.md +++ b/docs/ai/quickstarts/build-vector-search-app.md @@ -26,8 +26,6 @@ In this quickstart, you create a .NET console app to perform semantic search on :::zone-end -[!INCLUDE [clone-sample-repo](includes/clone-sample-repo.md)] - ## Interact with your data using vector stores Vector stores or vector databases are essential for tasks like semantic search, Retrieval Augmented Generation (RAG), and other scenarios that require grounding generative AI responses. While relational databases and document databases are optimized for structured and semi-structured data, vector databases are built to efficiently store, index, and manage data represented as embedding vectors. As a result, the indexing and search algorithms used by vector databases are optimized to efficiently retrieve data that can be used downstream in your applications. @@ -171,7 +169,7 @@ Complete the following steps to create a .NET console app that can: :::zone target="docs" pivot="openai" - :::code language="csharp" source="snippets/chat-with-data/openai/program.cs" range="49-57"::: + :::code language="csharp" source="snippets/chat-with-data/openai/program.cs" id="EmbeddingGenerator"::: :::zone-end @@ -197,11 +195,10 @@ Complete the following steps to create a .NET console app that can: ## Clean up resources -When you no longer need the sample application or resources, remove the corresponding deployment and all resources. +If you no longer need them, delete the Azure OpenAI resource and GPT-4 model deployment. -```azdeveloper -azd down -``` +1. In the [Azure Portal](https://aka.ms/azureportal), navigate to the Azure OpenAI resource. +1. Select the Azure OpenAI resource, and then select **Delete**. :::zone-end diff --git a/docs/ai/quickstarts/chat-local-model.md b/docs/ai/quickstarts/chat-local-model.md index bc7ca0c11e373..94c4489987ce5 100644 --- a/docs/ai/quickstarts/chat-local-model.md +++ b/docs/ai/quickstarts/chat-local-model.md @@ -84,12 +84,12 @@ The Semantic Kernel SDK provides many services and features to connect to AI mod The preceding code accomplishes the following: - - Creates an `OllamaChatClient` that implements the `IChatClient` interface. - - This interface provides a loosely coupled abstraction you can use to chat with AI Models. - - You can later change the underlying chat client implementation to another model, such as Azure OpenAI, without changing any other code. - - Creates a `ChatHistory` object to store the messages between the user and the AI model. - - Retrieves a prompt from the user and stores it in the `ChatHistory`. - - Sends the chat data to the AI model to generate a response. + * Creates an `OllamaChatClient` that implements the `IChatClient` interface. + * This interface provides a loosely coupled abstraction you can use to chat with AI Models. + * You can later change the underlying chat client implementation to another model, such as Azure OpenAI, without changing any other code. + * Creates a `ChatHistory` object to store the messages between the user and the AI model. + * Retrieves a prompt from the user and stores it in the `ChatHistory`. + * Sends the chat data to the AI model to generate a response. > [!NOTE] > Ollama runs on port 11434 by default, which is why the AI model endpoint is set to `http://localhost:11434`. @@ -146,4 +146,4 @@ The Semantic Kernel SDK provides many services and features to connect to AI mod ## Next steps -- [Generate text and conversations with .NET and Azure OpenAI Completions](/training/modules/open-ai-dotnet-text-completions/) +* [Generate text and conversations with .NET and Azure OpenAI Completions](/training/modules/open-ai-dotnet-text-completions/) diff --git a/docs/ai/quickstarts/create-assistant.md b/docs/ai/quickstarts/create-assistant.md index a91f448eaad4f..4f0053c4846d5 100644 --- a/docs/ai/quickstarts/create-assistant.md +++ b/docs/ai/quickstarts/create-assistant.md @@ -107,27 +107,27 @@ Complete the following steps to create a .NET console app and add the package ne ## Create the AI assistant client -1. Open the _Program.cs_ file and replace the contents of the file with the following code to create the required clients: +1. Open the `Program.cs` file and replace the contents of the file with the following code to create the required clients: - :::code language="csharp" source="snippets/assistants/program.cs" range="0-17" ::: + :::code language="csharp" source="snippets/assistants/program.cs" id="CreateClient" ::: 1. Create an in-memory sample document and upload it to the `OpenAIFileClient`: - :::code language="csharp" source="snippets/assistants/program.cs" range="19-53" ::: + :::code language="csharp" source="snippets/assistants/program.cs" id="CreateDocument" ::: 1. Enable file search and code interpreter tooling capabilities via the `AssistantCreationOptions`: - :::code language="csharp" source="snippets/assistants/program.cs" range="55-78" ::: + :::code language="csharp" source="snippets/assistants/program.cs" id="EnableTools" ::: 1. Create the `Assistant` and a thread to manage interactions between the user and the assistant: - :::code language="csharp" source="snippets/assistants/program.cs" range="80-105" ::: + :::code language="csharp" source="snippets/assistants/program.cs" id="CreateAssistant" ::: 1. Print the messages and save the generated image from the conversation with the assistant: - :::code language="csharp" source="snippets/assistants/program.cs" range="107-147" ::: + :::code language="csharp" source="snippets/assistants/program.cs" id="ProcessMessages" ::: - Locate and open the saved image in the app *bin* directory, which should resemble the following: + Locate and open the saved image in the app `bin` directory, which should resemble the following: :::image type="content" source="../media/assistants/generated-sales-graph.png" alt-text="A graph showing the visualization generated by the AI model."::: diff --git a/docs/ai/quickstarts/evaluate-ai-response.md b/docs/ai/quickstarts/evaluate-ai-response.md index 7373ac005f6b9..e515cc9b7caff 100644 --- a/docs/ai/quickstarts/evaluate-ai-response.md +++ b/docs/ai/quickstarts/evaluate-ai-response.md @@ -96,6 +96,13 @@ Complete the following steps to create an MSTest project that connects to the `g Run the test using your preferred test workflow, for example, by using the CLI command `dotnet test` or through [Test Explorer](/visualstudio/test/run-unit-tests-with-test-explorer). +## Clean up resources + +If you no longer need them, delete the Azure OpenAI resource and GPT-4 model deployment. + +1. In the [Azure Portal](https://aka.ms/azureportal), navigate to the Azure OpenAI resource. +1. Select the Azure OpenAI resource, and then select **Delete**. + ## Next steps - Evaluate the responses from different OpenAI models. diff --git a/docs/ai/quickstarts/generate-images.md b/docs/ai/quickstarts/generate-images.md index 523948bb2bc94..14dc00733ea6e 100644 --- a/docs/ai/quickstarts/generate-images.md +++ b/docs/ai/quickstarts/generate-images.md @@ -28,8 +28,6 @@ In this quickstart, you learn how to create a .NET console app to generate image [!INCLUDE [semantic-kernel](includes/semantic-kernel.md)] -[!INCLUDE [clone-sample-repo](includes/clone-sample-repo.md)] - ## Create the app Complete the following steps to create a .NET console app to connect to an AI model. @@ -134,11 +132,10 @@ Complete the following steps to create a .NET console app to connect to an AI mo ## Clean up resources -When you no longer need the sample application or resources, remove the corresponding deployment and all resources. +If you no longer need them, delete the Azure OpenAI resource and GPT-4 model deployment. -```azdeveloper -azd down -``` +1. In the [Azure Portal](https://aka.ms/azureportal), navigate to the Azure OpenAI resource. +1. Select the Azure OpenAI resource, and then select **Delete**. :::zone-end diff --git a/docs/ai/quickstarts/includes/clone-sample-repo.md b/docs/ai/quickstarts/includes/clone-sample-repo.md deleted file mode 100644 index f32ffcae527e2..0000000000000 --- a/docs/ai/quickstarts/includes/clone-sample-repo.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -author: jmatthiesen -ms.author: jomatthi -ms.date: 07/03/2024 -ms.topic: include ---- - -## (Optional) Clone the sample repository - -You can create your own app using the steps in the sections ahead, or you can clone the GitHub repository that contains the completed sample apps for all of the quickstarts. If you plan to use Azure OpenAI, the sample repo is also structured as an Azure Developer CLI template that can provision an Azure OpenAI resource for you. - -```bash -git clone https://github.com/dotnet/ai-samples.git -``` diff --git a/docs/ai/quickstarts/includes/create-ai-service.md b/docs/ai/quickstarts/includes/create-ai-service.md index c1d7cdcac7a95..f80d2af925333 100644 --- a/docs/ai/quickstarts/includes/create-ai-service.md +++ b/docs/ai/quickstarts/includes/create-ai-service.md @@ -1,7 +1,5 @@ ## Create the AI service -# [Azure Portal or Azure CLI](#tab/azure-cli) - 1. To provision an Azure OpenAI service and model, complete the steps in the [Create and deploy an Azure OpenAI Service resource](/azure/ai-services/openai/how-to/create-resource) article. 1. From a terminal or command prompt, navigate to the root of your project directory. @@ -13,9 +11,3 @@ dotnet user-secrets set AZURE_OPENAI_ENDPOINT dotnet user-secrets set AZURE_OPENAI_GPT_NAME ``` - -# [Azure Developer CLI](#tab/azd) - -[!INCLUDE [deploy-azd](deploy-azd.md)] - ---- diff --git a/docs/ai/quickstarts/includes/deploy-azd.md b/docs/ai/quickstarts/includes/deploy-azd.md deleted file mode 100644 index 8c9e87040603c..0000000000000 --- a/docs/ai/quickstarts/includes/deploy-azd.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -author: jmatthiesen -ms.author: jomatthi -ms.date: 07/03/2024 -ms.topic: include ---- - -The sample GitHub repository is structured as an Azure Developer CLI (`azd`) template, which `azd` can use to provision the Azure OpenAI service and model for you. - -1. From a terminal or command prompt, navigate to the `src\quickstarts\azure-openai` directory of the sample repo. -1. Run the `azd up` command to provision the Azure OpenAI resources. It might take several minutes to create the Azure OpenAI service and deploy the model. - - ```azdeveloper - azd up - ``` - - `azd` also configures the required user secrets for the sample app, such as the Azure OpenAI endpoint and model name. diff --git a/docs/ai/quickstarts/prompt-model.md b/docs/ai/quickstarts/prompt-model.md index 91ad6212bab08..0e171a3245960 100644 --- a/docs/ai/quickstarts/prompt-model.md +++ b/docs/ai/quickstarts/prompt-model.md @@ -31,8 +31,6 @@ In this quickstart, you learn how to create a .NET console chat app to connect t [!INCLUDE [semantic-kernel](includes/semantic-kernel.md)] -[!INCLUDE [clone-sample-repo](includes/clone-sample-repo.md)] - ## Create the app Complete the following steps to create a .NET console app to connect to an AI model. @@ -141,11 +139,10 @@ The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Micr ## Clean up resources -When you no longer need the sample application or resources, remove the corresponding deployment and all resources. +If you no longer need them, delete the Azure OpenAI resource and GPT-4 model deployment. -```azdeveloper -azd down -``` +1. In the [Azure Portal](https://aka.ms/azureportal), navigate to the Azure OpenAI resource. +1. Select the Azure OpenAI resource, and then select **Delete**. :::zone-end diff --git a/docs/ai/quickstarts/snippets/assistants/Program.cs b/docs/ai/quickstarts/snippets/assistants/Program.cs index a07a79a4ff21f..9aa359ddf995f 100644 --- a/docs/ai/quickstarts/snippets/assistants/Program.cs +++ b/docs/ai/quickstarts/snippets/assistants/Program.cs @@ -1,4 +1,5 @@ -using OpenAI; +// +using OpenAI; using OpenAI.Assistants; using OpenAI.Files; using Azure.AI.OpenAI; @@ -15,7 +16,9 @@ #pragma warning disable OPENAI001 AssistantClient assistantClient = openAIClient.GetAssistantClient(); OpenAIFileClient fileClient = openAIClient.GetOpenAIFileClient(); +// +// // Create an in-memory document to upload to the file client using Stream document = BinaryData.FromBytes(""" { @@ -51,7 +54,9 @@ document, "monthly_sales.json", FileUploadPurpose.Assistants); +// +// // Configure the assistant options AssistantCreationOptions assistantOptions = new() { @@ -76,7 +81,9 @@ } }, }; +// +// // Create the assistant Assistant assistant = assistantClient.CreateAssistant("gpt-4o", assistantOptions); @@ -100,10 +107,13 @@ var messages = assistantClient.GetMessagesAsync( threadRun.ThreadId, new MessageCollectionOptions() - { + { Order = MessageCollectionOrder.Ascending }); +// +// +// Process the messages from the assistant await foreach (ThreadMessage message in messages) { // Print out the messages from the assistant @@ -144,4 +154,5 @@ } } Console.WriteLine(); -} \ No newline at end of file +} +// diff --git a/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/Program.cs b/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/Program.cs index eb552f0715ab8..1e482546971c5 100644 --- a/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/Program.cs +++ b/docs/ai/quickstarts/snippets/build-chat-app/azure-openai/Program.cs @@ -3,6 +3,7 @@ using Azure.AI.OpenAI; using Azure.Identity; +// IConfigurationRoot config = new ConfigurationBuilder().AddUserSecrets().Build(); string endpoint = config["AZURE_OPENAI_ENDPOINT"]; string deployment = config["AZURE_OPENAI_GPT_NAME"]; @@ -11,7 +12,9 @@ new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential()) .GetChatClient(deployment) .AsIChatClient(); +// +// // Start the conversation with context for the AI model List chatHistory = [ @@ -30,7 +33,9 @@ the local nature on the hikes when making a recommendation. At the end of your response, ask if there is anything else you can help with. """) ]; +// +// while (true) { // Get user prompt and add to chat history @@ -50,3 +55,4 @@ the local nature on the hikes when making a recommendation. At the end of your chatHistory.Add(new ChatMessage(ChatRole.Assistant, response)); Console.WriteLine(); } +// diff --git a/docs/ai/quickstarts/snippets/build-chat-app/openai/Program.cs b/docs/ai/quickstarts/snippets/build-chat-app/openai/Program.cs index 81108f8da5feb..3fc36782e7ee9 100644 --- a/docs/ai/quickstarts/snippets/build-chat-app/openai/Program.cs +++ b/docs/ai/quickstarts/snippets/build-chat-app/openai/Program.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.AI; using OpenAI; +// var config = new ConfigurationBuilder().AddUserSecrets().Build(); string model = config["ModelName"]; string key = config["OpenAIKey"]; @@ -9,7 +10,9 @@ // Create the IChatClient IChatClient chatClient = new OpenAIClient(key).GetChatClient(model).AsIChatClient(); +// +// // Start the conversation with context for the AI model List chatHistory = [ @@ -28,7 +31,10 @@ the local nature on the hikes when making a recommendation. At the end of your response, ask if there is anything else you can help with. """) ]; +// +// +// Loop to get user input and stream AI response while (true) { // Get user prompt and add to chat history @@ -48,3 +54,4 @@ the local nature on the hikes when making a recommendation. At the end of your chatHistory.Add(new ChatMessage(ChatRole.Assistant, response)); Console.WriteLine(); } +// diff --git a/docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs b/docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs index 042987331b192..21d7f98c26ee4 100644 --- a/docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs +++ b/docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs @@ -45,6 +45,7 @@ string model = config["ModelName"]; string key = config["OpenAIKey"]; +// // Create the embedding generator. IEmbeddingGenerator> generator = new OpenAIClient(new ApiKeyCredential(key)) @@ -55,6 +56,7 @@ var vectorStore = new InMemoryVectorStore(); IVectorStoreRecordCollection cloudServicesStore = vectorStore.GetCollection("cloudServices"); await cloudServicesStore.CreateCollectionIfNotExistsAsync(); +// foreach (CloudService service in cloudServices) { diff --git a/docs/ai/quickstarts/snippets/function-calling/azure-openai/Program.cs b/docs/ai/quickstarts/snippets/function-calling/azure-openai/Program.cs index d3080e4b5626e..a8d3a53750ed0 100644 --- a/docs/ai/quickstarts/snippets/function-calling/azure-openai/Program.cs +++ b/docs/ai/quickstarts/snippets/function-calling/azure-openai/Program.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Configuration; +// +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.AI; using Azure.AI.OpenAI; using Azure.Identity; @@ -13,6 +14,7 @@ .GetChatClient(deployment).AsIChatClient()) .UseFunctionInvocation() .Build(); +// // Add a new plugin with a local .NET function that should be available to the AI model var chatOptions = new ChatOptions diff --git a/docs/ai/quickstarts/snippets/function-calling/openai/Program.cs b/docs/ai/quickstarts/snippets/function-calling/openai/Program.cs index 57f1e6fb4f4b6..d515895d5c11c 100644 --- a/docs/ai/quickstarts/snippets/function-calling/openai/Program.cs +++ b/docs/ai/quickstarts/snippets/function-calling/openai/Program.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.AI; +// +using Microsoft.Extensions.AI; using Microsoft.Extensions.Configuration; using OpenAI; @@ -10,7 +11,9 @@ new ChatClientBuilder(new OpenAIClient(key).GetChatClient(model ?? "gpt-4o").AsIChatClient()) .UseFunctionInvocation() .Build(); +// +// // Add a new plugin with a local .NET function // that should be available to the AI model. var chatOptions = new ChatOptions @@ -24,7 +27,9 @@ "get_current_weather", "Get the current weather in a given location")] }; +// +// // System prompt to provide context. List chatHistory = [new(ChatRole.System, """ You are a hiking enthusiast who helps people discover fun hikes in their area. You are upbeat and friendly. @@ -37,3 +42,4 @@ You are a hiking enthusiast who helps people discover fun hikes in their area. Y ChatResponse response = await client.GetResponseAsync(chatHistory, chatOptions); Console.WriteLine($"Assistant >>> {response.Text}"); +// diff --git a/docs/ai/quickstarts/structured-output.md b/docs/ai/quickstarts/structured-output.md index 117d23e0725f6..e4b9656ca1a1a 100644 --- a/docs/ai/quickstarts/structured-output.md +++ b/docs/ai/quickstarts/structured-output.md @@ -111,6 +111,13 @@ Complete the following steps to create a console app that connects to the `gpt-4 Sentiment: Neutral ``` +## Clean up resources + +If you no longer need them, delete the Azure OpenAI resource and GPT-4 model deployment. + +1. In the [Azure Portal](https://aka.ms/azureportal), navigate to the Azure OpenAI resource. +1. Select the Azure OpenAI resource, and then select **Delete**. + ## See also - [Structured outputs (Azure OpenAI Service)](/azure/ai-services/openai/how-to/structured-outputs) diff --git a/docs/ai/quickstarts/use-function-calling.md b/docs/ai/quickstarts/use-function-calling.md index 6f37aa0c7a995..31c7b2443a5bd 100644 --- a/docs/ai/quickstarts/use-function-calling.md +++ b/docs/ai/quickstarts/use-function-calling.md @@ -31,8 +31,6 @@ In this quickstart, you create a .NET console AI chat app to connect to an AI mo [!INCLUDE [semantic-kernel](includes/semantic-kernel.md)] -[!INCLUDE [clone-sample-repo](includes/clone-sample-repo.md)] - ## Create the app Complete the following steps to create a .NET console app to connect to an AI model. @@ -111,7 +109,7 @@ The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Micr :::zone target="docs" pivot="azure-openai" - :::code language="csharp" source="snippets/function-calling/azure-openai/program.cs" range="1-16"::: + :::code language="csharp" source="snippets/function-calling/azure-openai/program.cs" id="GetChatClient"::: > [!NOTE] > searches for authentication credentials from your local tooling. If you aren't using the `azd` template to provision the Azure OpenAI resource, you'll need to assign the `Azure AI Developer` role to the account you used to sign in to Visual Studio or the Azure CLI. For more information, see [Authenticate to Azure AI services with .NET](../azure-ai-services-authentication.md). @@ -120,17 +118,17 @@ The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Micr :::zone target="docs" pivot="openai" - :::code language="csharp" source="snippets/function-calling/openai/program.cs" range="1-14"::: + :::code language="csharp" source="snippets/function-calling/openai/program.cs" id="GetChatClient"::: :::zone-end 1. Create a new `ChatOptions` object that contains an inline function the AI model can call to get the current weather. The function declaration includes a delegate to run logic, and name and description parameters to describe the purpose of the function to the AI model. - :::code language="csharp" source="snippets/function-calling/openai/program.cs" range="16-26"::: + :::code language="csharp" source="snippets/function-calling/openai/program.cs" id="AddOptions"::: 1. Add a system prompt to the `chatHistory` to provide context and instructions to the model. Send a user prompt with a question that requires the AI model to call the registered function to properly answer the question. - :::code language="csharp" source="snippets/function-calling/openai/program.cs" range="28-40"::: + :::code language="csharp" source="snippets/function-calling/openai/program.cs" id="PromptModel"::: 1. Use the `dotnet run` command to run the app: @@ -144,11 +142,10 @@ The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Micr ## Clean up resources -When you no longer need the sample application or resources, remove the corresponding deployment and all resources. +If you no longer need them, delete the Azure OpenAI resource and GPT-4 model deployment. -```azdeveloper -azd down -``` +1. In the [Azure Portal](https://aka.ms/azureportal), navigate to the Azure OpenAI resource. +1. Select the Azure OpenAI resource, and then select **Delete**. :::zone-end