From d7369be42f2bd965a571d6de8d4b32ee619844b0 Mon Sep 17 00:00:00 2001 From: Andreas Volkmann Date: Fri, 18 Oct 2024 13:10:49 -0700 Subject: [PATCH] Simplify samples (#3845) authored-by: Andreas Volkmann --- .../samples/AutoGen.BasicSamples/Program.cs | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/dotnet/samples/AutoGen.BasicSamples/Program.cs b/dotnet/samples/AutoGen.BasicSamples/Program.cs index 6cad02ac7cd6..5afbd8ec15e1 100644 --- a/dotnet/samples/AutoGen.BasicSamples/Program.cs +++ b/dotnet/samples/AutoGen.BasicSamples/Program.cs @@ -5,28 +5,29 @@ using AutoGen.BasicSample; //Define allSamples collection for all examples -List>> allSamples = new List>>(); - -// When a new sample is created please add them to the allSamples collection -allSamples.Add(new Tuple>("Assistant Agent", async () => { await Example01_AssistantAgent.RunAsync(); })); -allSamples.Add(new Tuple>("Two-agent Math Chat", async () => { await Example02_TwoAgent_MathChat.RunAsync(); })); -allSamples.Add(new Tuple>("Agent Function Call", async () => { await Example03_Agent_FunctionCall.RunAsync(); })); -allSamples.Add(new Tuple>("Dynamic Group Chat Coding Task", async () => { await Example04_Dynamic_GroupChat_Coding_Task.RunAsync(); })); -allSamples.Add(new Tuple>("DALL-E and GPT4v", async () => { await Example05_Dalle_And_GPT4V.RunAsync(); })); -allSamples.Add(new Tuple>("User Proxy Agent", async () => { await Example06_UserProxyAgent.RunAsync(); })); -allSamples.Add(new Tuple>("Dynamic Group Chat - Calculate Fibonacci", async () => { await Example07_Dynamic_GroupChat_Calculate_Fibonacci.RunAsync(); })); -allSamples.Add(new Tuple>("LM Studio", async () => { await Example08_LMStudio.RunAsync(); })); -allSamples.Add(new Tuple>("Semantic Kernel", async () => { await Example10_SemanticKernel.RunAsync(); })); -allSamples.Add(new Tuple>("Sequential Group Chat", async () => { await Sequential_GroupChat_Example.RunAsync(); })); -allSamples.Add(new Tuple>("Two Agent - Fill Application", async () => { await TwoAgent_Fill_Application.RunAsync(); })); -allSamples.Add(new Tuple>("Mistal Client Agent - Token Count", async () => { await Example14_MistralClientAgent_TokenCount.RunAsync(); })); -allSamples.Add(new Tuple>("GPT4v - Binary Data Image", async () => { await Example15_GPT4V_BinaryDataImageMessage.RunAsync(); })); -allSamples.Add(new Tuple>("ReAct Agent", async () => { await Example17_ReActAgent.RunAsync(); })); +var allSamples = new List<(string, Func)> +{ + // When a new sample is created please add them to the allSamples collection + ("Assistant Agent", Example01_AssistantAgent.RunAsync), + ("Two-agent Math Chat", Example02_TwoAgent_MathChat.RunAsync), + ("Agent Function Call", Example03_Agent_FunctionCall.RunAsync), + ("Dynamic Group Chat Coding Task", Example04_Dynamic_GroupChat_Coding_Task.RunAsync), + ("DALL-E and GPT4v", Example05_Dalle_And_GPT4V.RunAsync), + ("User Proxy Agent", Example06_UserProxyAgent.RunAsync), + ("Dynamic Group Chat - Calculate Fibonacci", Example07_Dynamic_GroupChat_Calculate_Fibonacci.RunAsync), + ("LM Studio", Example08_LMStudio.RunAsync), + ("Semantic Kernel", Example10_SemanticKernel.RunAsync), + ("Sequential Group Chat", Sequential_GroupChat_Example.RunAsync), + ("Two Agent - Fill Application", TwoAgent_Fill_Application.RunAsync), + ("Mistral Client Agent - Token Count", Example14_MistralClientAgent_TokenCount.RunAsync), + ("GPT4v - Binary Data Image", Example15_GPT4V_BinaryDataImageMessage.RunAsync), + ("ReAct Agent", Example17_ReActAgent.RunAsync) +}; -int idx = 1; -Dictionary>> map = new Dictionary>>(); Console.WriteLine("Available Examples:\n\n"); -foreach (Tuple> sample in allSamples) +var idx = 1; +var map = new Dictionary)>(); +foreach (var sample in allSamples) { map.Add(idx, sample); Console.WriteLine("{0}. {1}", idx++, sample.Item1); @@ -41,7 +42,7 @@ { break; } - int val = Convert.ToInt32(input); + var val = Convert.ToInt32(input); if (!map.ContainsKey(val)) { Console.WriteLine("Invalid choice");