diff --git a/dotnet/agent-framework-dotnet.slnx b/dotnet/agent-framework-dotnet.slnx index ad74b1f003..0490ce2aa6 100644 --- a/dotnet/agent-framework-dotnet.slnx +++ b/dotnet/agent-framework-dotnet.slnx @@ -24,6 +24,11 @@ + + + + + diff --git a/dotnet/demos/.editorconfig b/dotnet/demos/.editorconfig new file mode 100644 index 0000000000..0e87de9ec1 --- /dev/null +++ b/dotnet/demos/.editorconfig @@ -0,0 +1,8 @@ +# 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/MinimalConsole/MinimalConsole.csproj b/dotnet/demos/MinimalConsole/MinimalConsole.csproj new file mode 100644 index 0000000000..62e6ae5b56 --- /dev/null +++ b/dotnet/demos/MinimalConsole/MinimalConsole.csproj @@ -0,0 +1,19 @@ + + + + Exe + $(ProjectsTargetFrameworks) + $(ProjectsDebugTargetFrameworks) + + + + + + + + + + + + + diff --git a/dotnet/demos/MinimalConsole/Program.cs b/dotnet/demos/MinimalConsole/Program.cs new file mode 100644 index 0000000000..8935856ffb --- /dev/null +++ b/dotnet/demos/MinimalConsole/Program.cs @@ -0,0 +1,27 @@ +// 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; + +[Description("Get the weather for a given location.")] +static string GetWeather([Description("The location to get the weather for.")] string location) +{ + return $"The weather in {location} is cloudy with a high of 15°C."; +} + +IChatClient chatClient = new AzureOpenAIClient( + new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")!), + new AzureCliCredential()) + .GetChatClient("gpt-4o-mini") + .AsIChatClient(); + +AIAgent agent = new ChatClientAgent( + chatClient, + 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?"));