From 7dee184ae491dfb23042faa377b48bf095213d91 Mon Sep 17 00:00:00 2001 From: Mark Wallace <127216156+markwallace-microsoft@users.noreply.github.com> Date: Tue, 2 Sep 2025 11:52:07 +0100 Subject: [PATCH] .NET: Organize the .Net samples (#578) * Organize the .Net samples * Organize the .Net samples * Merge latest from main * Update sample to also include function calling telemetry (#577) * Move package installation instructions to user-guide (#572) * Move package installation instructions to user-guide * Update user-documentation-dotnet/getting-started/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update docs/docs-templates/getting-started/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * .NET: Add SK-AF Migration Samples for Responses API. (#575) * Responses wip * Adding OpenAI Responses Migration samples * Address all samples and code for Azure and OpenAI Responses Migration code * Update dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step02_ReasoningModel/Program.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Organize the .Net samples * Organize the .Net samples * Merge latest from main * Use Agent rather than AIAgent * Rename agents getting started samples * Use singular Agent --------- Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- dotnet/agent-framework-dotnet.slnx | 103 +++++++------- dotnet/demos/.editorconfig | 8 -- dotnet/demos/Directory.Build.props | 20 --- dotnet/demos/MinimalConsole/Program.cs | 26 ---- dotnet/demos/MinimalConsole/README.md | 30 ---- .../AgentOpenTelemetry.csproj | 4 +- .../AgentOpenTelemetry/Program.cs | 0 .../AgentOpenTelemetry/README.md | 0 .../AgentOpenTelemetry/start-demo.ps1 | 0 .../AgentOrchestration.csproj} | 8 +- .../{ => AgentOrchestration}/AgentSample.cs | 0 .../InMemoryActorStateStorageExample.cs | 0 .../ConcurrentOrchestration_Intro.cs | 0 ...rentOrchestration_With_StructuredOutput.cs | 0 .../GroupChatOrchestration_Intro.cs | 0 .../GroupChatOrchestration_With_AIManager.cs | 0 ...upChatOrchestration_With_HumanInTheLoop.cs | 0 .../HandoffOrchestration_Intro.cs | 0 ...ndoffOrchestration_With_StructuredInput.cs | 0 .../SequentialOrchestration_Foundry_Agents.cs | 0 .../SequentialOrchestration_Intro.cs | 0 .../SequentialOrchestration_Multi_Agent.cs | 0 ...quentialOrchestration_With_Cancellation.cs | 0 .../Resources/Hamlet_full_play_summary.txt | 0 .../Resources/employees.pdf | Bin .../Resources/groceries.txt | 0 .../Agent_With_A2A/Agent_With_A2A.csproj} | 6 +- .../AgentProviders/Agent_With_A2A}/Program.cs | 0 .../AgentProviders/Agent_With_A2A}/README.md | 0 .../Agent_With_AzureFoundry.csproj} | 4 +- .../Agent_With_AzureFoundry}/Program.cs | 0 .../Agent_With_AzureFoundry}/README.md | 0 ...ent_With_AzureOpenAIChatCompletion.csproj} | 4 +- .../Program.cs | 0 .../README.md | 0 .../Agent_With_AzureOpenAIResponses.csproj} | 4 +- .../Program.cs | 0 .../README.md | 0 .../Agent_With_ONNX/Agent_With_ONNX.csproj} | 2 +- .../Agent_With_ONNX}/Program.cs | 0 .../AgentProviders/Agent_With_ONNX}/README.md | 0 .../Agent_With_OpenAIChatCompletion.csproj} | 4 +- .../Program.cs | 0 .../README.md | 0 .../Agent_With_OpenAIResponses.csproj} | 4 +- .../Agent_With_OpenAIResponses}/Program.cs | 0 .../Agent_With_OpenAIResponses}/README.md | 0 .../AgentProviders}/README.md | 0 .../Agent_Step01_Running.csproj} | 4 +- .../Agents/Agent_Step01_Running}/Program.cs | 0 ...Agent_Step02_MultiturnConversation.csproj} | 4 +- .../Program.cs | 0 .../Agent_Step03_UsingFunctionTools.csproj | 23 +++ .../Program.cs | 0 ...04_UsingFunctionToolsWithApprovals.csproj} | 4 +- .../Program.cs | 0 .../Agent_Step05_StructuredOutput.csproj | 23 +++ .../Agent_Step05_StructuredOutput}/Program.cs | 0 ...Agent_Step06_PersistedConversations.csproj | 23 +++ .../Program.cs | 0 ...Agent_Step07_3rdPartyThreadStorage.csproj} | 4 +- .../Program.cs | 0 .../Agent_Step08_Telemetry.csproj} | 4 +- .../Agents/Agent_Step08_Telemetry}/Program.cs | 0 .../Agent_Step09_DependencyInjection.csproj} | 4 +- .../Program.cs | 0 .../samples/GettingStarted/Agents/README.md | 75 ++++++++++ .../Custom/Custom_OpenAIChatClientAgent.cs | 41 ------ .../Providers/AIAgent_With_OpenAIAssistant.cs | 58 -------- dotnet/samples/GettingStarted/README.md | 12 ++ ...atClientAgent_UsingCodeInterpreterTools.cs | 125 ----------------- ...07_ChatClientAgent_UsingFileSearchTools.cs | 131 ------------------ dotnet/samples/GettingStartedSteps/README.md | 75 ---------- ...05_ChatClientAgent_StructuredOutput.csproj | 23 --- ...tClientAgent_PersistedConversations.csproj | 23 --- ...gent_With_AzureOpenAIChatCompletion.csproj | 23 --- .../AIAgent_With_AzureOpenAIResponses.csproj | 23 --- dotnet/samples/README.md | 8 +- 78 files changed, 239 insertions(+), 698 deletions(-) delete mode 100644 dotnet/demos/.editorconfig delete mode 100644 dotnet/demos/Directory.Build.props delete mode 100644 dotnet/demos/MinimalConsole/Program.cs delete mode 100644 dotnet/demos/MinimalConsole/README.md rename dotnet/{demos => samples/GettingStarted}/AgentOpenTelemetry/AgentOpenTelemetry.csproj (82%) rename dotnet/{demos => samples/GettingStarted}/AgentOpenTelemetry/Program.cs (100%) rename dotnet/{demos => samples/GettingStarted}/AgentOpenTelemetry/README.md (100%) rename dotnet/{demos => samples/GettingStarted}/AgentOpenTelemetry/start-demo.ps1 (100%) rename dotnet/samples/GettingStarted/{GettingStarted.csproj => AgentOrchestration/AgentOrchestration.csproj} (82%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/AgentSample.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/InMemoryActorStateStorageExample.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/ConcurrentOrchestration_Intro.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/ConcurrentOrchestration_With_StructuredOutput.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/GroupChatOrchestration_Intro.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/GroupChatOrchestration_With_AIManager.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/GroupChatOrchestration_With_HumanInTheLoop.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/HandoffOrchestration_Intro.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/HandoffOrchestration_With_StructuredInput.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/SequentialOrchestration_Foundry_Agents.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/SequentialOrchestration_Intro.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/SequentialOrchestration_Multi_Agent.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Orchestration/SequentialOrchestration_With_Cancellation.cs (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Resources/Hamlet_full_play_summary.txt (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Resources/employees.pdf (100%) rename dotnet/samples/GettingStarted/{ => AgentOrchestration}/Resources/groceries.txt (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_A2A/AIAgent_With_A2A.csproj => GettingStarted/AgentProviders/Agent_With_A2A/Agent_With_A2A.csproj} (75%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_A2A => GettingStarted/AgentProviders/Agent_With_A2A}/Program.cs (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_A2A => GettingStarted/AgentProviders/Agent_With_A2A}/README.md (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_AzureFoundry/AIAgent_With_AzureFoundry.csproj => GettingStarted/AgentProviders/Agent_With_AzureFoundry/Agent_With_AzureFoundry.csproj} (63%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_AzureFoundry => GettingStarted/AgentProviders/Agent_With_AzureFoundry}/Program.cs (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_AzureFoundry => GettingStarted/AgentProviders/Agent_With_AzureFoundry}/README.md (100%) rename dotnet/samples/{GettingStartedSteps/Step02_ChatClientAgent_MultiturnConversation/Step02_ChatClientAgent_MultiturnConversation.csproj => GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion/Agent_With_AzureOpenAIChatCompletion.csproj} (66%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIChatCompletion => GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion}/Program.cs (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIChatCompletion => GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion}/README.md (100%) rename dotnet/samples/{GettingStartedSteps/Step03_ChatClientAgent_UsingFunctionTools/Step03_ChatClientAgent_UsingFunctionTools.csproj => GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses/Agent_With_AzureOpenAIResponses.csproj} (66%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIResponses => GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses}/Program.cs (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIResponses => GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses}/README.md (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_ONNX/AIAgent_With_ONNX.csproj => GettingStarted/AgentProviders/Agent_With_ONNX/Agent_With_ONNX.csproj} (77%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_ONNX => GettingStarted/AgentProviders/Agent_With_ONNX}/Program.cs (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_ONNX => GettingStarted/AgentProviders/Agent_With_ONNX}/README.md (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIResponses/AIAgent_With_OpenAIResponses.csproj => GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/Agent_With_OpenAIChatCompletion.csproj} (54%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIChatCompletion => GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion}/Program.cs (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIChatCompletion => GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion}/README.md (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIChatCompletion/AIAgent_With_OpenAIChatCompletion.csproj => GettingStarted/AgentProviders/Agent_With_OpenAIResponses/Agent_With_OpenAIResponses.csproj} (54%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIResponses => GettingStarted/AgentProviders/Agent_With_OpenAIResponses}/Program.cs (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIResponses => GettingStarted/AgentProviders/Agent_With_OpenAIResponses}/README.md (100%) rename dotnet/samples/{HowToCreateAnAIAgentByProvider => GettingStarted/AgentProviders}/README.md (100%) rename dotnet/{demos/MinimalConsole/MinimalConsole.csproj => samples/GettingStarted/Agents/Agent_Step01_Running/Agent_Step01_Running.csproj} (66%) rename dotnet/samples/{GettingStartedSteps/Step01_ChatClientAgent_Running => GettingStarted/Agents/Agent_Step01_Running}/Program.cs (100%) rename dotnet/samples/{GettingStartedSteps/Step01_ChatClientAgent_Running/Step01_ChatClientAgent_Running.csproj => GettingStarted/Agents/Agent_Step02_MultiturnConversation/Agent_Step02_MultiturnConversation.csproj} (66%) rename dotnet/samples/{GettingStartedSteps/Step02_ChatClientAgent_MultiturnConversation => GettingStarted/Agents/Agent_Step02_MultiturnConversation}/Program.cs (100%) create mode 100644 dotnet/samples/GettingStarted/Agents/Agent_Step03_UsingFunctionTools/Agent_Step03_UsingFunctionTools.csproj rename dotnet/samples/{GettingStartedSteps/Step03_ChatClientAgent_UsingFunctionTools => GettingStarted/Agents/Agent_Step03_UsingFunctionTools}/Program.cs (100%) rename dotnet/samples/{GettingStartedSteps/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals.csproj => GettingStarted/Agents/Agent_Step04_UsingFunctionToolsWithApprovals/Agent_Step04_UsingFunctionToolsWithApprovals.csproj} (68%) rename dotnet/samples/{GettingStartedSteps/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals => GettingStarted/Agents/Agent_Step04_UsingFunctionToolsWithApprovals}/Program.cs (100%) create mode 100644 dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/Agent_Step05_StructuredOutput.csproj rename dotnet/samples/{GettingStartedSteps/Step05_ChatClientAgent_StructuredOutput => GettingStarted/Agents/Agent_Step05_StructuredOutput}/Program.cs (100%) create mode 100644 dotnet/samples/GettingStarted/Agents/Agent_Step06_PersistedConversations/Agent_Step06_PersistedConversations.csproj rename dotnet/samples/{GettingStartedSteps/Step06_ChatClientAgent_PersistedConversations => GettingStarted/Agents/Agent_Step06_PersistedConversations}/Program.cs (100%) rename dotnet/samples/{GettingStartedSteps/Step07_ChatClientAgent_3rdPartyThreadStorage/Step07_ChatClientAgent_3rdPartyThreadStorage.csproj => GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Agent_Step07_3rdPartyThreadStorage.csproj} (71%) rename dotnet/samples/{GettingStartedSteps/Step07_ChatClientAgent_3rdPartyThreadStorage => GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage}/Program.cs (100%) rename dotnet/samples/{GettingStartedSteps/Step08_ChatClientAgent_Telemetry/Step08_ChatClientAgent_Telemetry.csproj => GettingStarted/Agents/Agent_Step08_Telemetry/Agent_Step08_Telemetry.csproj} (70%) rename dotnet/samples/{GettingStartedSteps/Step08_ChatClientAgent_Telemetry => GettingStarted/Agents/Agent_Step08_Telemetry}/Program.cs (100%) rename dotnet/samples/{GettingStartedSteps/Step09_ChatClientAgent_DependencyInjection/Step09_ChatClientAgent_DependencyInjection.csproj => GettingStarted/Agents/Agent_Step09_DependencyInjection/Agent_Step09_DependencyInjection.csproj} (69%) rename dotnet/samples/{GettingStartedSteps/Step09_ChatClientAgent_DependencyInjection => GettingStarted/Agents/Agent_Step09_DependencyInjection}/Program.cs (100%) create mode 100644 dotnet/samples/GettingStarted/Agents/README.md delete mode 100644 dotnet/samples/GettingStarted/Custom/Custom_OpenAIChatClientAgent.cs delete mode 100644 dotnet/samples/GettingStarted/Providers/AIAgent_With_OpenAIAssistant.cs create mode 100644 dotnet/samples/GettingStarted/README.md delete mode 100644 dotnet/samples/GettingStarted/Steps/Step03_ChatClientAgent_UsingCodeInterpreterTools.cs delete mode 100644 dotnet/samples/GettingStarted/Steps/Step07_ChatClientAgent_UsingFileSearchTools.cs delete mode 100644 dotnet/samples/GettingStartedSteps/README.md delete mode 100644 dotnet/samples/GettingStartedSteps/Step05_ChatClientAgent_StructuredOutput/Step05_ChatClientAgent_StructuredOutput.csproj delete mode 100644 dotnet/samples/GettingStartedSteps/Step06_ChatClientAgent_PersistedConversations/Step06_ChatClientAgent_PersistedConversations.csproj delete mode 100644 dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIChatCompletion/AIAgent_With_AzureOpenAIChatCompletion.csproj delete mode 100644 dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIResponses/AIAgent_With_AzureOpenAIResponses.csproj diff --git a/dotnet/agent-framework-dotnet.slnx b/dotnet/agent-framework-dotnet.slnx index 126efa7272..71d8e77312 100644 --- a/dotnet/agent-framework-dotnet.slnx +++ b/dotnet/agent-framework-dotnet.slnx @@ -4,44 +4,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -49,27 +13,54 @@ - - - - - - - - - - - + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dotnet/demos/.editorconfig b/dotnet/demos/.editorconfig deleted file mode 100644 index 0e87de9ec1..0000000000 --- a/dotnet/demos/.editorconfig +++ /dev/null @@ -1,8 +0,0 @@ -# Suppressing errors for Sample projects under dotnet/samples folder -[*.cs] -dotnet_diagnostic.CA2007.severity = none # Do not directly await a Task -dotnet_diagnostic.CS1591.severity = none # Missing XML comment for publicly visible type or member -dotnet_diagnostic.IDE1006.severity = warning # Naming rule violations -dotnet_diagnostic.VSTHRD111.severity = none # Use .ConfigureAwait(bool) is hidden by default, set to none to prevent IDE from changing on autosave -dotnet_diagnostic.CA1716.severity = none # Add summary to documentation comment. -dotnet_diagnostic.CA2000.severity = none # Call System.IDisposable.Dispose on object before all references to it are out of scope diff --git a/dotnet/demos/Directory.Build.props b/dotnet/demos/Directory.Build.props deleted file mode 100644 index cfcc22dab6..0000000000 --- a/dotnet/demos/Directory.Build.props +++ /dev/null @@ -1,20 +0,0 @@ - - - - true - AllEnabledByDefault - latest - true - Debug;Release;Publish - $(NoWarn);NU5104 - - - - - - - - - - - diff --git a/dotnet/demos/MinimalConsole/Program.cs b/dotnet/demos/MinimalConsole/Program.cs deleted file mode 100644 index 3daf37b8be..0000000000 --- a/dotnet/demos/MinimalConsole/Program.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using System; -using System.ComponentModel; -using Azure.AI.OpenAI; -using Azure.Identity; -using Microsoft.Extensions.AI; -using Microsoft.Extensions.AI.Agents; -using OpenAI; - -var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set."); -var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "gpt-4o-mini"; - -[Description("Get the weather for a given location.")] -static string GetWeather([Description("The location to get the weather for.")] string location) - => $"The weather in {location} is cloudy with a high of 15°C."; - -AIAgent agent = new AzureOpenAIClient( - new Uri(endpoint), - new AzureCliCredential()) - .GetChatClient(deploymentName) - .CreateAIAgent( - instructions: "You are a helpful assistant, you can help the user with weather information.", - tools: [AIFunctionFactory.Create(GetWeather)]); - -Console.WriteLine(await agent.RunAsync("What's the weather in Amsterdam?")); diff --git a/dotnet/demos/MinimalConsole/README.md b/dotnet/demos/MinimalConsole/README.md deleted file mode 100644 index dfba693f6c..0000000000 --- a/dotnet/demos/MinimalConsole/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Minimal Console Application - -This demo shows a very basic console application, that uses the agent framework with Azure OpenAI and function calling. - -## Overview - -## Prerequisites - -- .NET 8.0 SDK or later -- Azure OpenAI service endpoint and deployment configured -- Azure CLI installed and authenticated (for Azure credential authentication) - -## Configuration - -### Azure OpenAI Setup -Set the following environment variables: -```powershell -$env:AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/" -$env:AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o-mini" # Optional, defaults to gpt-4o-mini -``` - -**Note**: This demo uses Azure CLI credentials for authentication. Make sure you're logged in with `az login` and have access to the Azure OpenAI resource. - -## Running the Demo - -```powershell -cd dotnet/demos/MinimalConsole -dotnet build -dotnet run --no-build -``` diff --git a/dotnet/demos/AgentOpenTelemetry/AgentOpenTelemetry.csproj b/dotnet/samples/GettingStarted/AgentOpenTelemetry/AgentOpenTelemetry.csproj similarity index 82% rename from dotnet/demos/AgentOpenTelemetry/AgentOpenTelemetry.csproj rename to dotnet/samples/GettingStarted/AgentOpenTelemetry/AgentOpenTelemetry.csproj index 16b7d163a8..d552be2c50 100644 --- a/dotnet/demos/AgentOpenTelemetry/AgentOpenTelemetry.csproj +++ b/dotnet/samples/GettingStarted/AgentOpenTelemetry/AgentOpenTelemetry.csproj @@ -26,8 +26,8 @@ - - + + diff --git a/dotnet/demos/AgentOpenTelemetry/Program.cs b/dotnet/samples/GettingStarted/AgentOpenTelemetry/Program.cs similarity index 100% rename from dotnet/demos/AgentOpenTelemetry/Program.cs rename to dotnet/samples/GettingStarted/AgentOpenTelemetry/Program.cs diff --git a/dotnet/demos/AgentOpenTelemetry/README.md b/dotnet/samples/GettingStarted/AgentOpenTelemetry/README.md similarity index 100% rename from dotnet/demos/AgentOpenTelemetry/README.md rename to dotnet/samples/GettingStarted/AgentOpenTelemetry/README.md diff --git a/dotnet/demos/AgentOpenTelemetry/start-demo.ps1 b/dotnet/samples/GettingStarted/AgentOpenTelemetry/start-demo.ps1 similarity index 100% rename from dotnet/demos/AgentOpenTelemetry/start-demo.ps1 rename to dotnet/samples/GettingStarted/AgentOpenTelemetry/start-demo.ps1 diff --git a/dotnet/samples/GettingStarted/GettingStarted.csproj b/dotnet/samples/GettingStarted/AgentOrchestration/AgentOrchestration.csproj similarity index 82% rename from dotnet/samples/GettingStarted/GettingStarted.csproj rename to dotnet/samples/GettingStarted/AgentOrchestration/AgentOrchestration.csproj index 9b5ff872ee..5caf5fd086 100644 --- a/dotnet/samples/GettingStarted/GettingStarted.csproj +++ b/dotnet/samples/GettingStarted/AgentOrchestration/AgentOrchestration.csproj @@ -40,10 +40,10 @@ - - - - + + + + diff --git a/dotnet/samples/GettingStarted/AgentSample.cs b/dotnet/samples/GettingStarted/AgentOrchestration/AgentSample.cs similarity index 100% rename from dotnet/samples/GettingStarted/AgentSample.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/AgentSample.cs diff --git a/dotnet/samples/GettingStarted/InMemoryActorStateStorageExample.cs b/dotnet/samples/GettingStarted/AgentOrchestration/InMemoryActorStateStorageExample.cs similarity index 100% rename from dotnet/samples/GettingStarted/InMemoryActorStateStorageExample.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/InMemoryActorStateStorageExample.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/ConcurrentOrchestration_Intro.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/ConcurrentOrchestration_Intro.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/ConcurrentOrchestration_Intro.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/ConcurrentOrchestration_Intro.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/ConcurrentOrchestration_With_StructuredOutput.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/ConcurrentOrchestration_With_StructuredOutput.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/ConcurrentOrchestration_With_StructuredOutput.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/ConcurrentOrchestration_With_StructuredOutput.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/GroupChatOrchestration_Intro.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/GroupChatOrchestration_Intro.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/GroupChatOrchestration_Intro.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/GroupChatOrchestration_Intro.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/GroupChatOrchestration_With_AIManager.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/GroupChatOrchestration_With_AIManager.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/GroupChatOrchestration_With_AIManager.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/GroupChatOrchestration_With_AIManager.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/GroupChatOrchestration_With_HumanInTheLoop.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/GroupChatOrchestration_With_HumanInTheLoop.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/GroupChatOrchestration_With_HumanInTheLoop.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/GroupChatOrchestration_With_HumanInTheLoop.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/HandoffOrchestration_Intro.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/HandoffOrchestration_Intro.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/HandoffOrchestration_Intro.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/HandoffOrchestration_Intro.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/HandoffOrchestration_With_StructuredInput.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/HandoffOrchestration_With_StructuredInput.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/HandoffOrchestration_With_StructuredInput.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/HandoffOrchestration_With_StructuredInput.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/SequentialOrchestration_Foundry_Agents.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/SequentialOrchestration_Foundry_Agents.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/SequentialOrchestration_Foundry_Agents.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/SequentialOrchestration_Foundry_Agents.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/SequentialOrchestration_Intro.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/SequentialOrchestration_Intro.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/SequentialOrchestration_Intro.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/SequentialOrchestration_Intro.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/SequentialOrchestration_Multi_Agent.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/SequentialOrchestration_Multi_Agent.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/SequentialOrchestration_Multi_Agent.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/SequentialOrchestration_Multi_Agent.cs diff --git a/dotnet/samples/GettingStarted/Orchestration/SequentialOrchestration_With_Cancellation.cs b/dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/SequentialOrchestration_With_Cancellation.cs similarity index 100% rename from dotnet/samples/GettingStarted/Orchestration/SequentialOrchestration_With_Cancellation.cs rename to dotnet/samples/GettingStarted/AgentOrchestration/Orchestration/SequentialOrchestration_With_Cancellation.cs diff --git a/dotnet/samples/GettingStarted/Resources/Hamlet_full_play_summary.txt b/dotnet/samples/GettingStarted/AgentOrchestration/Resources/Hamlet_full_play_summary.txt similarity index 100% rename from dotnet/samples/GettingStarted/Resources/Hamlet_full_play_summary.txt rename to dotnet/samples/GettingStarted/AgentOrchestration/Resources/Hamlet_full_play_summary.txt diff --git a/dotnet/samples/GettingStarted/Resources/employees.pdf b/dotnet/samples/GettingStarted/AgentOrchestration/Resources/employees.pdf similarity index 100% rename from dotnet/samples/GettingStarted/Resources/employees.pdf rename to dotnet/samples/GettingStarted/AgentOrchestration/Resources/employees.pdf diff --git a/dotnet/samples/GettingStarted/Resources/groceries.txt b/dotnet/samples/GettingStarted/AgentOrchestration/Resources/groceries.txt similarity index 100% rename from dotnet/samples/GettingStarted/Resources/groceries.txt rename to dotnet/samples/GettingStarted/AgentOrchestration/Resources/groceries.txt diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_A2A/AIAgent_With_A2A.csproj b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_A2A/Agent_With_A2A.csproj similarity index 75% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_A2A/AIAgent_With_A2A.csproj rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_A2A/Agent_With_A2A.csproj index d6c65c58dd..fd2e0b7b80 100644 --- a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_A2A/AIAgent_With_A2A.csproj +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_A2A/Agent_With_A2A.csproj @@ -1,4 +1,4 @@ - + Exe @@ -16,7 +16,7 @@ - + - + \ No newline at end of file diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_A2A/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_A2A/Program.cs similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_A2A/Program.cs rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_A2A/Program.cs diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_A2A/README.md b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_A2A/README.md similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_A2A/README.md rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_A2A/README.md diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureFoundry/AIAgent_With_AzureFoundry.csproj b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundry/Agent_With_AzureFoundry.csproj similarity index 63% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureFoundry/AIAgent_With_AzureFoundry.csproj rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundry/Agent_With_AzureFoundry.csproj index 294ec1455e..9da22b3573 100644 --- a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureFoundry/AIAgent_With_AzureFoundry.csproj +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundry/Agent_With_AzureFoundry.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureFoundry/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundry/Program.cs similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureFoundry/Program.cs rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundry/Program.cs diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureFoundry/README.md b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundry/README.md similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureFoundry/README.md rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundry/README.md diff --git a/dotnet/samples/GettingStartedSteps/Step02_ChatClientAgent_MultiturnConversation/Step02_ChatClientAgent_MultiturnConversation.csproj b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion/Agent_With_AzureOpenAIChatCompletion.csproj similarity index 66% rename from dotnet/samples/GettingStartedSteps/Step02_ChatClientAgent_MultiturnConversation/Step02_ChatClientAgent_MultiturnConversation.csproj rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion/Agent_With_AzureOpenAIChatCompletion.csproj index 15185f869a..3c80c1527e 100644 --- a/dotnet/samples/GettingStartedSteps/Step02_ChatClientAgent_MultiturnConversation/Step02_ChatClientAgent_MultiturnConversation.csproj +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion/Agent_With_AzureOpenAIChatCompletion.csproj @@ -16,8 +16,8 @@ - - + + diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIChatCompletion/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion/Program.cs similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIChatCompletion/Program.cs rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion/Program.cs diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIChatCompletion/README.md b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion/README.md similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIChatCompletion/README.md rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion/README.md diff --git a/dotnet/samples/GettingStartedSteps/Step03_ChatClientAgent_UsingFunctionTools/Step03_ChatClientAgent_UsingFunctionTools.csproj b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses/Agent_With_AzureOpenAIResponses.csproj similarity index 66% rename from dotnet/samples/GettingStartedSteps/Step03_ChatClientAgent_UsingFunctionTools/Step03_ChatClientAgent_UsingFunctionTools.csproj rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses/Agent_With_AzureOpenAIResponses.csproj index 15185f869a..3c80c1527e 100644 --- a/dotnet/samples/GettingStartedSteps/Step03_ChatClientAgent_UsingFunctionTools/Step03_ChatClientAgent_UsingFunctionTools.csproj +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses/Agent_With_AzureOpenAIResponses.csproj @@ -16,8 +16,8 @@ - - + + diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIResponses/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses/Program.cs similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIResponses/Program.cs rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses/Program.cs diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIResponses/README.md b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses/README.md similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIResponses/README.md rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses/README.md diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_ONNX/AIAgent_With_ONNX.csproj b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_ONNX/Agent_With_ONNX.csproj similarity index 77% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_ONNX/AIAgent_With_ONNX.csproj rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_ONNX/Agent_With_ONNX.csproj index 599d3f6698..69320f79c0 100644 --- a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_ONNX/AIAgent_With_ONNX.csproj +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_ONNX/Agent_With_ONNX.csproj @@ -14,7 +14,7 @@ - + diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_ONNX/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_ONNX/Program.cs similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_ONNX/Program.cs rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_ONNX/Program.cs diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_ONNX/README.md b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_ONNX/README.md similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_ONNX/README.md rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_ONNX/README.md diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIResponses/AIAgent_With_OpenAIResponses.csproj b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/Agent_With_OpenAIChatCompletion.csproj similarity index 54% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIResponses/AIAgent_With_OpenAIResponses.csproj rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/Agent_With_OpenAIChatCompletion.csproj index 6f38c09c64..bbce14eb4b 100644 --- a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIResponses/AIAgent_With_OpenAIResponses.csproj +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/Agent_With_OpenAIChatCompletion.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIChatCompletion/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/Program.cs similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIChatCompletion/Program.cs rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/Program.cs diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIChatCompletion/README.md b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/README.md similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIChatCompletion/README.md rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/README.md diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIChatCompletion/AIAgent_With_OpenAIChatCompletion.csproj b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/Agent_With_OpenAIResponses.csproj similarity index 54% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIChatCompletion/AIAgent_With_OpenAIChatCompletion.csproj rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/Agent_With_OpenAIResponses.csproj index 6f38c09c64..bbce14eb4b 100644 --- a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIChatCompletion/AIAgent_With_OpenAIChatCompletion.csproj +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/Agent_With_OpenAIResponses.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIResponses/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/Program.cs similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIResponses/Program.cs rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/Program.cs diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIResponses/README.md b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/README.md similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_OpenAIResponses/README.md rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/README.md diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/README.md b/dotnet/samples/GettingStarted/AgentProviders/README.md similarity index 100% rename from dotnet/samples/HowToCreateAnAIAgentByProvider/README.md rename to dotnet/samples/GettingStarted/AgentProviders/README.md diff --git a/dotnet/demos/MinimalConsole/MinimalConsole.csproj b/dotnet/samples/GettingStarted/Agents/Agent_Step01_Running/Agent_Step01_Running.csproj similarity index 66% rename from dotnet/demos/MinimalConsole/MinimalConsole.csproj rename to dotnet/samples/GettingStarted/Agents/Agent_Step01_Running/Agent_Step01_Running.csproj index 078b334181..3c80c1527e 100644 --- a/dotnet/demos/MinimalConsole/MinimalConsole.csproj +++ b/dotnet/samples/GettingStarted/Agents/Agent_Step01_Running/Agent_Step01_Running.csproj @@ -16,8 +16,8 @@ - - + + diff --git a/dotnet/samples/GettingStartedSteps/Step01_ChatClientAgent_Running/Program.cs b/dotnet/samples/GettingStarted/Agents/Agent_Step01_Running/Program.cs similarity index 100% rename from dotnet/samples/GettingStartedSteps/Step01_ChatClientAgent_Running/Program.cs rename to dotnet/samples/GettingStarted/Agents/Agent_Step01_Running/Program.cs diff --git a/dotnet/samples/GettingStartedSteps/Step01_ChatClientAgent_Running/Step01_ChatClientAgent_Running.csproj b/dotnet/samples/GettingStarted/Agents/Agent_Step02_MultiturnConversation/Agent_Step02_MultiturnConversation.csproj similarity index 66% rename from dotnet/samples/GettingStartedSteps/Step01_ChatClientAgent_Running/Step01_ChatClientAgent_Running.csproj rename to dotnet/samples/GettingStarted/Agents/Agent_Step02_MultiturnConversation/Agent_Step02_MultiturnConversation.csproj index 15185f869a..3c80c1527e 100644 --- a/dotnet/samples/GettingStartedSteps/Step01_ChatClientAgent_Running/Step01_ChatClientAgent_Running.csproj +++ b/dotnet/samples/GettingStarted/Agents/Agent_Step02_MultiturnConversation/Agent_Step02_MultiturnConversation.csproj @@ -16,8 +16,8 @@ - - + + diff --git a/dotnet/samples/GettingStartedSteps/Step02_ChatClientAgent_MultiturnConversation/Program.cs b/dotnet/samples/GettingStarted/Agents/Agent_Step02_MultiturnConversation/Program.cs similarity index 100% rename from dotnet/samples/GettingStartedSteps/Step02_ChatClientAgent_MultiturnConversation/Program.cs rename to dotnet/samples/GettingStarted/Agents/Agent_Step02_MultiturnConversation/Program.cs diff --git a/dotnet/samples/GettingStarted/Agents/Agent_Step03_UsingFunctionTools/Agent_Step03_UsingFunctionTools.csproj b/dotnet/samples/GettingStarted/Agents/Agent_Step03_UsingFunctionTools/Agent_Step03_UsingFunctionTools.csproj new file mode 100644 index 0000000000..3c80c1527e --- /dev/null +++ b/dotnet/samples/GettingStarted/Agents/Agent_Step03_UsingFunctionTools/Agent_Step03_UsingFunctionTools.csproj @@ -0,0 +1,23 @@ + + + + Exe + net9.0 + 12 + + enable + disable + + + + + + + + + + + + + + diff --git a/dotnet/samples/GettingStartedSteps/Step03_ChatClientAgent_UsingFunctionTools/Program.cs b/dotnet/samples/GettingStarted/Agents/Agent_Step03_UsingFunctionTools/Program.cs similarity index 100% rename from dotnet/samples/GettingStartedSteps/Step03_ChatClientAgent_UsingFunctionTools/Program.cs rename to dotnet/samples/GettingStarted/Agents/Agent_Step03_UsingFunctionTools/Program.cs diff --git a/dotnet/samples/GettingStartedSteps/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals.csproj b/dotnet/samples/GettingStarted/Agents/Agent_Step04_UsingFunctionToolsWithApprovals/Agent_Step04_UsingFunctionToolsWithApprovals.csproj similarity index 68% rename from dotnet/samples/GettingStartedSteps/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals.csproj rename to dotnet/samples/GettingStarted/Agents/Agent_Step04_UsingFunctionToolsWithApprovals/Agent_Step04_UsingFunctionToolsWithApprovals.csproj index 47e49128ab..d83018dd29 100644 --- a/dotnet/samples/GettingStartedSteps/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals.csproj +++ b/dotnet/samples/GettingStarted/Agents/Agent_Step04_UsingFunctionToolsWithApprovals/Agent_Step04_UsingFunctionToolsWithApprovals.csproj @@ -17,8 +17,8 @@ - - + + diff --git a/dotnet/samples/GettingStartedSteps/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals/Program.cs b/dotnet/samples/GettingStarted/Agents/Agent_Step04_UsingFunctionToolsWithApprovals/Program.cs similarity index 100% rename from dotnet/samples/GettingStartedSteps/Step04_ChatClientAgent_UsingFunctionToolsWithApprovals/Program.cs rename to dotnet/samples/GettingStarted/Agents/Agent_Step04_UsingFunctionToolsWithApprovals/Program.cs diff --git a/dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/Agent_Step05_StructuredOutput.csproj b/dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/Agent_Step05_StructuredOutput.csproj new file mode 100644 index 0000000000..3c80c1527e --- /dev/null +++ b/dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/Agent_Step05_StructuredOutput.csproj @@ -0,0 +1,23 @@ + + + + Exe + net9.0 + 12 + + enable + disable + + + + + + + + + + + + + + diff --git a/dotnet/samples/GettingStartedSteps/Step05_ChatClientAgent_StructuredOutput/Program.cs b/dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/Program.cs similarity index 100% rename from dotnet/samples/GettingStartedSteps/Step05_ChatClientAgent_StructuredOutput/Program.cs rename to dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/Program.cs diff --git a/dotnet/samples/GettingStarted/Agents/Agent_Step06_PersistedConversations/Agent_Step06_PersistedConversations.csproj b/dotnet/samples/GettingStarted/Agents/Agent_Step06_PersistedConversations/Agent_Step06_PersistedConversations.csproj new file mode 100644 index 0000000000..3c80c1527e --- /dev/null +++ b/dotnet/samples/GettingStarted/Agents/Agent_Step06_PersistedConversations/Agent_Step06_PersistedConversations.csproj @@ -0,0 +1,23 @@ + + + + Exe + net9.0 + 12 + + enable + disable + + + + + + + + + + + + + + diff --git a/dotnet/samples/GettingStartedSteps/Step06_ChatClientAgent_PersistedConversations/Program.cs b/dotnet/samples/GettingStarted/Agents/Agent_Step06_PersistedConversations/Program.cs similarity index 100% rename from dotnet/samples/GettingStartedSteps/Step06_ChatClientAgent_PersistedConversations/Program.cs rename to dotnet/samples/GettingStarted/Agents/Agent_Step06_PersistedConversations/Program.cs diff --git a/dotnet/samples/GettingStartedSteps/Step07_ChatClientAgent_3rdPartyThreadStorage/Step07_ChatClientAgent_3rdPartyThreadStorage.csproj b/dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Agent_Step07_3rdPartyThreadStorage.csproj similarity index 71% rename from dotnet/samples/GettingStartedSteps/Step07_ChatClientAgent_3rdPartyThreadStorage/Step07_ChatClientAgent_3rdPartyThreadStorage.csproj rename to dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Agent_Step07_3rdPartyThreadStorage.csproj index 750a1c9ad7..68c0002c72 100644 --- a/dotnet/samples/GettingStartedSteps/Step07_ChatClientAgent_3rdPartyThreadStorage/Step07_ChatClientAgent_3rdPartyThreadStorage.csproj +++ b/dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Agent_Step07_3rdPartyThreadStorage.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/dotnet/samples/GettingStartedSteps/Step07_ChatClientAgent_3rdPartyThreadStorage/Program.cs b/dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Program.cs similarity index 100% rename from dotnet/samples/GettingStartedSteps/Step07_ChatClientAgent_3rdPartyThreadStorage/Program.cs rename to dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Program.cs diff --git a/dotnet/samples/GettingStartedSteps/Step08_ChatClientAgent_Telemetry/Step08_ChatClientAgent_Telemetry.csproj b/dotnet/samples/GettingStarted/Agents/Agent_Step08_Telemetry/Agent_Step08_Telemetry.csproj similarity index 70% rename from dotnet/samples/GettingStartedSteps/Step08_ChatClientAgent_Telemetry/Step08_ChatClientAgent_Telemetry.csproj rename to dotnet/samples/GettingStarted/Agents/Agent_Step08_Telemetry/Agent_Step08_Telemetry.csproj index 836c10a00f..96e2dfb566 100644 --- a/dotnet/samples/GettingStartedSteps/Step08_ChatClientAgent_Telemetry/Step08_ChatClientAgent_Telemetry.csproj +++ b/dotnet/samples/GettingStarted/Agents/Agent_Step08_Telemetry/Agent_Step08_Telemetry.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/dotnet/samples/GettingStartedSteps/Step08_ChatClientAgent_Telemetry/Program.cs b/dotnet/samples/GettingStarted/Agents/Agent_Step08_Telemetry/Program.cs similarity index 100% rename from dotnet/samples/GettingStartedSteps/Step08_ChatClientAgent_Telemetry/Program.cs rename to dotnet/samples/GettingStarted/Agents/Agent_Step08_Telemetry/Program.cs diff --git a/dotnet/samples/GettingStartedSteps/Step09_ChatClientAgent_DependencyInjection/Step09_ChatClientAgent_DependencyInjection.csproj b/dotnet/samples/GettingStarted/Agents/Agent_Step09_DependencyInjection/Agent_Step09_DependencyInjection.csproj similarity index 69% rename from dotnet/samples/GettingStartedSteps/Step09_ChatClientAgent_DependencyInjection/Step09_ChatClientAgent_DependencyInjection.csproj rename to dotnet/samples/GettingStarted/Agents/Agent_Step09_DependencyInjection/Agent_Step09_DependencyInjection.csproj index e2753ab403..eaf68b3e73 100644 --- a/dotnet/samples/GettingStartedSteps/Step09_ChatClientAgent_DependencyInjection/Step09_ChatClientAgent_DependencyInjection.csproj +++ b/dotnet/samples/GettingStarted/Agents/Agent_Step09_DependencyInjection/Agent_Step09_DependencyInjection.csproj @@ -17,8 +17,8 @@ - - + + diff --git a/dotnet/samples/GettingStartedSteps/Step09_ChatClientAgent_DependencyInjection/Program.cs b/dotnet/samples/GettingStarted/Agents/Agent_Step09_DependencyInjection/Program.cs similarity index 100% rename from dotnet/samples/GettingStartedSteps/Step09_ChatClientAgent_DependencyInjection/Program.cs rename to dotnet/samples/GettingStarted/Agents/Agent_Step09_DependencyInjection/Program.cs diff --git a/dotnet/samples/GettingStarted/Agents/README.md b/dotnet/samples/GettingStarted/Agents/README.md new file mode 100644 index 0000000000..87fad915ad --- /dev/null +++ b/dotnet/samples/GettingStarted/Agents/README.md @@ -0,0 +1,75 @@ +# Getting started with agents + +The getting started with agents samples demonstrate the fundamental concepts and functionalities +of single agents and can be used with any agent type. + +While the functionality can be used with any agent type, these samples use Azure OpenAI as the AI provider +and use ChatCompletion as the type of service. + +For other samples that demonstrate how to create and configure each type of agent that come with the agent framework, +see the [How to create an agent for each provider](../AgentProviders/README.md) samples. + +## Getting started with agents prerequisites + +Before you begin, ensure you have the following prerequisites: + +- .NET 8.0 SDK or later +- Azure OpenAI service endpoint and deployment configured +- Azure CLI installed and authenticated (for Azure credential authentication) + +**Note**: This demo uses Azure CLI credentials for authentication. Make sure you're logged in with `az login` and have access to the Azure OpenAI resource. For more information, see the [Azure CLI documentation](https://learn.microsoft.com/cli/azure/authenticate-azure-cli-interactively). + +## Samples + +|Sample|Description| +|---|---| +|[Running a simple agent](./Agents_Step01_Running/)|This sample demonstrates how to create and run a basic agent with instructions| +|[Multi-turn conversation with a simple agent](./Agents_Step02_MultiturnConversation/)|This sample demonstrates how to implement a multi-turn conversation with a simple agent| +|[Using function tools with a simple agent](./Agents_Step03_UsingFunctionTools/)|This sample demonstrates how to use function tools with a simple agent| +|[Using function tools with approvals](./Agents_Step04_UsingFunctionToolsWithApprovals/)|This sample demonstrates how to use function tools where approvals require human in the loop approvals before execution| +|[Structured output with a simple agent](./Agents_Step05_StructuredOutput/)|This sample demonstrates how to use structured output with a simple agent| +|[Persisted conversations with a simple agent](./Agents_Step06_PersistedConversations/)|This sample demonstrates how to persist conversations and reload them later. This is useful for cases where an agent is hosted in a stateless service| +|[3rd party thread storage with a simple agent](./Agents_Step07_3rdPartyThreadStorage/)|This sample demonstrates how to store conversation history in a 3rd party storage solution| +|[Telemetry with a simple agent](./Agents_Step08_Telemetry/)|This sample demonstrates how to add telemetry to a simple agent| +|[Dependency injection with a simple agent](./Agents_Step09_DependencyInjection/)|This sample demonstrates how to add and resolve an agent with a dependency injection container| + +## Running the samples from the console + +To run the samples, navigate to the desired sample directory, e.g. + +```powershell +cd Agents_Step01_Running +``` + +Set the following environment variables: + +```powershell +$env:AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/" # Replace with your Azure OpenAI resource endpoint +$env:AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o-mini" # Optional, defaults to gpt-4o-mini +``` + +If the variables are not set, you will be prompted for the values when running the samples. + +Execute the following command to build the sample: + +```powershell +dotnet build +``` + +Execute the following command to run the sample: + +```powershell +dotnet run --no-build +``` + +Or just build and run in one step: + +```powershell +dotnet run +``` + +## Running the samples from Visual Studio + +Open the solution in Visual Studio and set the desired sample project as the startup project. Then, run the project using the built-in debugger or by pressing `F5`. + +You will be prompted for any required environment variables if they are not already set. diff --git a/dotnet/samples/GettingStarted/Custom/Custom_OpenAIChatClientAgent.cs b/dotnet/samples/GettingStarted/Custom/Custom_OpenAIChatClientAgent.cs deleted file mode 100644 index 2363b06cb4..0000000000 --- a/dotnet/samples/GettingStarted/Custom/Custom_OpenAIChatClientAgent.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using Microsoft.Extensions.Logging; -using Microsoft.Shared.Samples; -using OpenAI; -using OpenAI.Chat; - -namespace Custom; - -/// -/// End-to-end sample showing how to use a custom . -/// -public sealed class Custom_OpenAIChatClientAgent(ITestOutputHelper output) : AgentSample(output) -{ - /// - /// This will create an instance of and run it. - /// - [Fact] - public async Task RunCustomChatClientAgent() - { - var chatClient = new OpenAIClient(TestConfiguration.OpenAI.ApiKey).GetChatClient(TestConfiguration.OpenAI.ChatModelId); - - var agent = new MyOpenAIChatClientAgent(chatClient); - - var chatMessage = new UserChatMessage("Tell me a joke about a pirate."); - var chatCompletion = await agent.RunAsync(chatMessage); - - Console.WriteLine(chatCompletion.Content.Last().Text); - } -} - -public class MyOpenAIChatClientAgent : OpenAIChatClientAgent -{ - private const string JokerName = "Joker"; - private const string JokerInstructions = "You are good at telling jokes."; - - public MyOpenAIChatClientAgent(ChatClient client, ILoggerFactory? loggerFactory = null) : - base(client, instructions: JokerInstructions, name: JokerName, loggerFactory: loggerFactory) - { - } -} diff --git a/dotnet/samples/GettingStarted/Providers/AIAgent_With_OpenAIAssistant.cs b/dotnet/samples/GettingStarted/Providers/AIAgent_With_OpenAIAssistant.cs deleted file mode 100644 index de658df825..0000000000 --- a/dotnet/samples/GettingStarted/Providers/AIAgent_With_OpenAIAssistant.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using Microsoft.Extensions.AI.Agents; -using Microsoft.Shared.Samples; -using OpenAI; - -#pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. - -namespace Providers; - -/// -/// End-to-end sample showing how to use with OpenAI Assistants. -/// -public sealed class AIAgent_With_OpenAIAssistant(ITestOutputHelper output) : AgentSample(output) -{ - private const string JokerName = "Joker"; - private const string JokerInstructions = "You are good at telling jokes."; - - [Fact] - public async Task RunWithAssistant() - { - // Get a client to create server side agents with. - var openAIClient = new OpenAIClient(TestConfiguration.OpenAI.ApiKey); - - // Get the agent directly from OpenAIClient. - AIAgent agent = openAIClient - .GetAssistantClient() - .CreateAIAgent( - model: TestConfiguration.OpenAI.ChatModelId, - name: JokerName, - instructions: JokerInstructions - ); - - // Start a new thread for the agent conversation. - AgentThread thread = agent.GetNewThread(); - - // Respond to user input - await RunAgentAsync("Tell me a joke about a pirate."); - await RunAgentAsync("Now add some emojis to the joke."); - - // Local function to invoke agent and display the conversation messages for the thread. - async Task RunAgentAsync(string input) - { - Console.WriteLine( - $""" - User: {input} - Assistant: - {await agent.RunAsync(input, thread)} - - """); - } - - // Cleanup - var assistantClient = openAIClient.GetAssistantClient(); - await assistantClient.DeleteThreadAsync(thread.ConversationId); - await assistantClient.DeleteAssistantAsync(agent.Id); - } -} diff --git a/dotnet/samples/GettingStarted/README.md b/dotnet/samples/GettingStarted/README.md new file mode 100644 index 0000000000..55cc7f7a97 --- /dev/null +++ b/dotnet/samples/GettingStarted/README.md @@ -0,0 +1,12 @@ +# Getting started + +The getting started samples demonstrate the fundamental concepts and functionalities +of the agent framework. + +## Samples + +|Sample|Description| +|---|---| +|[Agents](./Agents/README.md)|Getting started with agents| +|[Agent Providers](./AgentProviders/README.md)|Getting started with creating agents using various providers| +|[Agent Open Telemetry](./AgentOpenTelemetry/README.md)|Getting started with OpenTelemetry for agents| diff --git a/dotnet/samples/GettingStarted/Steps/Step03_ChatClientAgent_UsingCodeInterpreterTools.cs b/dotnet/samples/GettingStarted/Steps/Step03_ChatClientAgent_UsingCodeInterpreterTools.cs deleted file mode 100644 index d1f3bb4d52..0000000000 --- a/dotnet/samples/GettingStarted/Steps/Step03_ChatClientAgent_UsingCodeInterpreterTools.cs +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using System.Text; -using Azure.AI.Agents.Persistent; -using Azure.Identity; -using Microsoft.Extensions.AI; -using Microsoft.Extensions.AI.Agents; -using Microsoft.Shared.Samples; -using OpenAI.Files; - -namespace Steps; - -/// -/// Demonstrates how to use with code interpreter tools and file references. -/// Shows uploading files to different providers and using them with code interpreter capabilities to analyze data and generate responses. -/// -public sealed class Step03_ChatClientAgent_UsingCodeInterpreterTools(ITestOutputHelper output) : AgentSample(output) -{ - [Theory] - [InlineData(ChatClientProviders.AzureAIAgentsPersistent)] - [InlineData(ChatClientProviders.OpenAIAssistant)] - public async Task RunningWithFileReferenceAsync(ChatClientProviders provider) - { - var codeInterpreterTool = new HostedCodeInterpreterTool() - { - Inputs = [new HostedFileContent(await UploadFileAsync("Resources/groceries.txt", provider))] - }; - - var agentOptions = new ChatClientAgentOptions( - name: "HelpfulAssistant", - instructions: "You are a helpful assistant.", - tools: [codeInterpreterTool]); - - // Create the server-side agent Id when applicable (depending on the provider). - agentOptions.Id = await base.AgentCreateAsync(provider, agentOptions); - - using var chatClient = base.GetChatClient(provider, agentOptions); - - ChatClientAgent agent = new(chatClient, agentOptions); - - var thread = agent.GetNewThread(); - - // Prompt which allows to verify that the data was processed from file correctly and current datetime is returned. - const string Prompt = "Calculate the total number of items, identify the most frequently purchased item and return the result with today's datetime."; - - var assistantOutput = new StringBuilder(); - var codeInterpreterOutput = new StringBuilder(); - - await foreach (var update in agent.RunStreamingAsync(Prompt, thread)) - { - if (!string.IsNullOrWhiteSpace(update.Text)) - { - assistantOutput.Append(update.Text); - } - - if (update.RawRepresentation is ChatResponseUpdate chatUpdate && chatUpdate.RawRepresentation is not null) - { - codeInterpreterOutput.Append(GetCodeInterpreterOutput(chatUpdate.RawRepresentation, provider)); - } - } - - Console.WriteLine("Assistant Output:"); - Console.WriteLine(assistantOutput.ToString()); - - Console.WriteLine("Code interpreter Output:"); - Console.WriteLine(codeInterpreterOutput.ToString()); - - // Clean up the server-side agent after use when applicable (depending on the provider). - await base.AgentCleanUpAsync(provider, agent, thread); - } - - #region private - - /// - /// Uploads a file to the specified chat client provider and returns the file ID. - /// - /// Path to the file to be uploaded. - /// The chat client provider to use for uploading the file. - /// The ID of the uploaded file. - /// - private async Task UploadFileAsync(string filePath, ChatClientProviders provider) - { - switch (provider) - { - case ChatClientProviders.OpenAIAssistant: - var fileClient = new OpenAIFileClient(TestConfiguration.OpenAI.ApiKey); - OpenAIFile openAIFileInfo = await fileClient.UploadFileAsync(filePath, FileUploadPurpose.Assistants); - - return openAIFileInfo.Id; - case ChatClientProviders.AzureAIAgentsPersistent: - var persistentAgentsClient = new PersistentAgentsClient(TestConfiguration.AzureAI.Endpoint, new AzureCliCredential()); - PersistentAgentFileInfo persistentAgentFileInfo = await persistentAgentsClient.Files.UploadFileAsync(filePath, PersistentAgentFilePurpose.Agents); - - return persistentAgentFileInfo.Id; - - default: - throw new NotSupportedException($"Client provider {provider} is not supported."); - } - } - - /// - /// Depending on the provider, different strategies are used to extract the code interpreter output from the response raw representation. - /// - /// Raw representation of the response containing code interpreter output. - /// Provider of the chat client that is used to determine how to extract the output. - /// The code interpreter output as a string. - private static string? GetCodeInterpreterOutput(object rawRepresentation, ChatClientProviders provider) - => provider switch - { - ChatClientProviders.OpenAIAssistant - when rawRepresentation is OpenAI.Assistants.RunStepDetailsUpdate stepDetails => $"{stepDetails.CodeInterpreterInput}{string.Join( - string.Empty, - stepDetails.CodeInterpreterOutputs.SelectMany(l => l.Logs) - )}", - - ChatClientProviders.AzureAIAgentsPersistent - when rawRepresentation is Azure.AI.Agents.Persistent.RunStepDetailsUpdate stepDetails => $"{stepDetails.CodeInterpreterInput}{string.Join( - string.Empty, - stepDetails.CodeInterpreterOutputs.OfType().SelectMany(l => l.Logs) - )}", - _ => null, - }; - - #endregion -} diff --git a/dotnet/samples/GettingStarted/Steps/Step07_ChatClientAgent_UsingFileSearchTools.cs b/dotnet/samples/GettingStarted/Steps/Step07_ChatClientAgent_UsingFileSearchTools.cs deleted file mode 100644 index 8b26942177..0000000000 --- a/dotnet/samples/GettingStarted/Steps/Step07_ChatClientAgent_UsingFileSearchTools.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using System.Text; -using Azure.AI.Agents.Persistent; -using Azure.Identity; -using Microsoft.Extensions.AI; -using Microsoft.Extensions.AI.Agents; -using Microsoft.Shared.Samples; -using OpenAI.Files; -using OpenAI.VectorStores; - -namespace Steps; - -/// -/// Demonstrates how to use with file search tools and file references. -/// Shows uploading files to different providers and using them with file search capabilities to retrieve and analyze information from documents. -/// -public sealed class Step07_ChatClientAgent_UsingFileSearchTools(ITestOutputHelper output) : AgentSample(output) -{ - [Theory] - [InlineData(ChatClientProviders.AzureAIAgentsPersistent)] - [InlineData(ChatClientProviders.OpenAIAssistant)] - public async Task RunningWithFileReferenceAsync(ChatClientProviders provider) - { - // Upload a file to the specified provider. - var fileId = await UploadFileAsync("Resources/employees.pdf", provider); - - // Create a vector store for the uploaded file to enable file search capabilities. - var vectorStoreId = await CreateVectorStoreAsync([fileId], provider); - - // Create a file search tool that can access the vector store. - var fileSearchTool = new HostedFileSearchTool() - { - Inputs = [new HostedVectorStoreContent(vectorStoreId)], - }; - - var agentOptions = new ChatClientAgentOptions - { - Name = "FileSearchAssistant", - Instructions = "You are a helpful assistant that can search through uploaded documents to answer questions. Use the file search tool to find relevant information from the uploaded files.", - ChatOptions = new() { Tools = [fileSearchTool] } - }; - - // Create the server-side agent Id when applicable (depending on the provider). - agentOptions.Id = await base.AgentCreateAsync(provider, agentOptions); - - using var chatClient = base.GetChatClient(provider, agentOptions); - - ChatClientAgent agent = new(chatClient, agentOptions); - - var thread = agent.GetNewThread(); - - // Prompt which allows to verify that the file search functionality works correctly with the uploaded document. - const string Prompt = "Who is the youngest employee?"; - - var assistantOutput = new StringBuilder(); - - await foreach (var update in agent.RunStreamingAsync(Prompt, thread)) - { - if (!string.IsNullOrWhiteSpace(update.Text)) - { - assistantOutput.Append(update.Text); - } - } - - Console.WriteLine("Assistant Output:"); - Console.WriteLine(assistantOutput.ToString()); - - // Clean up the server-side agent after use when applicable (depending on the provider). - await base.AgentCleanUpAsync(provider, agent, thread); - } - - #region private - - /// - /// Uploads a file to the specified chat client provider and returns the file ID. - /// - /// Path to the file to be uploaded. - /// The chat client provider to use for uploading the file. - /// The ID of the uploaded file. - /// - private async Task UploadFileAsync(string filePath, ChatClientProviders provider) - { - switch (provider) - { - case ChatClientProviders.OpenAIAssistant: - var fileClient = new OpenAIFileClient(TestConfiguration.OpenAI.ApiKey); - OpenAIFile openAIFileInfo = await fileClient.UploadFileAsync(filePath, FileUploadPurpose.Assistants); - - return openAIFileInfo.Id; - case ChatClientProviders.AzureAIAgentsPersistent: - var persistentAgentsClient = new PersistentAgentsClient(TestConfiguration.AzureAI.Endpoint, new AzureCliCredential()); - PersistentAgentFileInfo persistentAgentFileInfo = await persistentAgentsClient.Files.UploadFileAsync(filePath, PersistentAgentFilePurpose.Agents); - - return persistentAgentFileInfo.Id; - - default: - throw new NotSupportedException($"Client provider {provider} is not supported."); - } - } - - private Task CreateVectorStoreAsync(IEnumerable fileIds, ChatClientProviders provider) - => provider switch - { - ChatClientProviders.OpenAIAssistant => CreateVectorStoreOpenAIAssistantAsync(fileIds), - ChatClientProviders.AzureAIAgentsPersistent => CreateVectorStoreAzureAIAgentsPersistentAsync(fileIds), - _ => throw new NotSupportedException($"Client provider {provider} is not supported."), - }; - - private async Task CreateVectorStoreOpenAIAssistantAsync(IEnumerable fileIds) - { - var vectorStoreClient = new VectorStoreClient(TestConfiguration.OpenAI.ApiKey); - VectorStoreCreationOptions options = new(); - foreach (var fileId in fileIds) - { - options.FileIds.Add(fileId); - } - - var vectorStore = await vectorStoreClient.CreateVectorStoreAsync(waitUntilCompleted: true, options); - return vectorStore.VectorStoreId; - } - - private async Task CreateVectorStoreAzureAIAgentsPersistentAsync(IEnumerable fileIds) - { - var client = new PersistentAgentsClient(TestConfiguration.AzureAI.Endpoint, new AzureCliCredential()); - var vectorStore = await client.VectorStores.CreateVectorStoreAsync(fileIds); - return vectorStore.Value.Id; - } - - #endregion -} diff --git a/dotnet/samples/GettingStartedSteps/README.md b/dotnet/samples/GettingStartedSteps/README.md deleted file mode 100644 index dec1438789..0000000000 --- a/dotnet/samples/GettingStartedSteps/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Getting started steps - -The getting started steps samples demonstrate the fundamental concepts and functionalities -of the agent framework and can be used with any agent type. - -While the functionality can be used with any agent type, these samples use Azure OpenAI as the AI provider -and use ChatCompletion as the type of service. - -For other samples that demonstrate how to create and configure each type of agent that come with the agent framework, -see the [How to create an AIAgent for each provider](../HowToCreateAnAIAgentByProvider/README.md) samples. - -## Getting started steps prerequisites - -Before you begin, ensure you have the following prerequisites: - -- .NET 8.0 SDK or later -- Azure OpenAI service endpoint and deployment configured -- Azure CLI installed and authenticated (for Azure credential authentication) - -**Note**: This demo uses Azure CLI credentials for authentication. Make sure you're logged in with `az login` and have access to the Azure OpenAI resource. For more information, see the [Azure CLI documentation](https://learn.microsoft.com/cli/azure/authenticate-azure-cli-interactively). - -## Samples - -|Sample|Description| -|---|---| -|[Running a simple agent](./Step01_ChatClientAgent_Running/)|This sample demonstrates how to create and run a basic agent with instructions| -|[Multi-turn conversation with a simple agent](./Step02_ChatClientAgent_MultiturnConversation/)|This sample demonstrates how to implement a multi-turn conversation with a simple agent| -|[Using function tools with a simple agent](./Step03_ChatClientAgent_UsingFunctionTools/)|This sample demonstrates how to use function tools with a simple agent| -|[Using function tools with approvals](./Step04_ChatClientAgent_UsingFunctionToolsWithApprovals/)|This sample demonstrates how to use function tools where approvals require human in the loop approvals before execution| -|[Structured output with a simple agent](./Step05_ChatClientAgent_StructuredOutput/)|This sample demonstrates how to use structured output with a simple agent| -|[Persisted conversations with a simple agent](./Step06_ChatClientAgent_PersistedConversations/)|This sample demonstrates how to persist conversations and reload them later. This is useful for cases where an agent is hosted in a stateless service| -|[3rd party thread storage with a simple agent](./Step07_ChatClientAgent_3rdPartyThreadStorage/)|This sample demonstrates how to store conversation history in a 3rd party storage solution| -|[Telemetry with a simple agent](./Step08_ChatClientAgent_Telemetry/)|This sample demonstrates how to add telemetry to a simple agent| -|[Dependency injection with a simple agent](./Step09_ChatClientAgent_DependencyInjection/)|This sample demonstrates how to add and resolve an agent with a dependency injection container| - -## Running the samples from the console - -To run the samples, navigate to the desired sample directory, e.g. - -```powershell -cd Step01_ChatClientAgent_Running -``` - -Set the following environment variables: - -```powershell -$env:AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/" # Replace with your Azure OpenAI resource endpoint -$env:AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o-mini" # Optional, defaults to gpt-4o-mini -``` - -If the variables are not set, you will be prompted for the values when running the samples. - -Execute the following command to build the sample: - -```powershell -dotnet build -``` - -Execute the following command to run the sample: - -```powershell -dotnet run --no-build -``` - -Or just build and run in one step: - -```powershell -dotnet run -``` - -## Running the samples from Visual Studio - -Open the solution in Visual Studio and set the desired sample project as the startup project. Then, run the project using the built-in debugger or by pressing `F5`. - -You will be prompted for any required environment variables if they are not already set. diff --git a/dotnet/samples/GettingStartedSteps/Step05_ChatClientAgent_StructuredOutput/Step05_ChatClientAgent_StructuredOutput.csproj b/dotnet/samples/GettingStartedSteps/Step05_ChatClientAgent_StructuredOutput/Step05_ChatClientAgent_StructuredOutput.csproj deleted file mode 100644 index 15185f869a..0000000000 --- a/dotnet/samples/GettingStartedSteps/Step05_ChatClientAgent_StructuredOutput/Step05_ChatClientAgent_StructuredOutput.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Exe - net9.0 - 12 - - enable - disable - - - - - - - - - - - - - - diff --git a/dotnet/samples/GettingStartedSteps/Step06_ChatClientAgent_PersistedConversations/Step06_ChatClientAgent_PersistedConversations.csproj b/dotnet/samples/GettingStartedSteps/Step06_ChatClientAgent_PersistedConversations/Step06_ChatClientAgent_PersistedConversations.csproj deleted file mode 100644 index 15185f869a..0000000000 --- a/dotnet/samples/GettingStartedSteps/Step06_ChatClientAgent_PersistedConversations/Step06_ChatClientAgent_PersistedConversations.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Exe - net9.0 - 12 - - enable - disable - - - - - - - - - - - - - - diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIChatCompletion/AIAgent_With_AzureOpenAIChatCompletion.csproj b/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIChatCompletion/AIAgent_With_AzureOpenAIChatCompletion.csproj deleted file mode 100644 index 15185f869a..0000000000 --- a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIChatCompletion/AIAgent_With_AzureOpenAIChatCompletion.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Exe - net9.0 - 12 - - enable - disable - - - - - - - - - - - - - - diff --git a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIResponses/AIAgent_With_AzureOpenAIResponses.csproj b/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIResponses/AIAgent_With_AzureOpenAIResponses.csproj deleted file mode 100644 index 15185f869a..0000000000 --- a/dotnet/samples/HowToCreateAnAIAgentByProvider/AIAgent_With_AzureOpenAIResponses/AIAgent_With_AzureOpenAIResponses.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Exe - net9.0 - 12 - - enable - disable - - - - - - - - - - - - - - diff --git a/dotnet/samples/README.md b/dotnet/samples/README.md index abe2298128..2d12c8fb49 100644 --- a/dotnet/samples/README.md +++ b/dotnet/samples/README.md @@ -13,11 +13,11 @@ were local agents. These are supported using various `AIAgent` subclasses. The samples are subdivided into the following categories: -- [Getting Started Steps](./GettingStartedSteps/README.md): Basic steps to get started with the agent framework. +- [Getting Started - Agents](./GettingStarted/Agents/README.md): Basic steps to get started with the agent framework. These samples demonstrate the fundamental concepts and functionalities of the agent framework when using the - `ChatClientAgent` and can be used with any underlying service that the `ChatClientAgent` supports. -- [How to create an AIAgent for each provider](./HowToCreateAnAIAgentByProvider/README.md): Shows how to create an AIAgent instance for a selection of providers. -- [Agent specific features](./AgentSpecificFeatures/README.md): Samples that showcase features specific to each type of agent. + `AIAgent` and can be used with any underlying service that provides an `AIAgent` implementation. +- [Getting Started - Agent Providers](./GettingStarted/AgentProviders/README.md): Shows how to create an AIAgent instance for a selection of providers. +- [Getting Started - Agent Telemetry](./GettingStarted/AgentOpenTelemetry/README.md): Demo which showcases the integration of OpenTelemetry with the Microsoft Agent Framework using Azure OpenAI and .NET Aspire Dashboard for telemetry visualization. ## Prerequisites