From 0f5dda26d21faae1346e9e87bdbf88afb089b028 Mon Sep 17 00:00:00 2001 From: Chaitanya Belwal Date: Tue, 13 Aug 2024 12:04:04 -0500 Subject: [PATCH] Updated Program.cs for Autogen.BasicSample to give a menu driven window making it easier to run variou Agent config. (#3346) --- dotnet/sample/AutoGen.BasicSamples/Program.cs | 57 ++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/dotnet/sample/AutoGen.BasicSamples/Program.cs b/dotnet/sample/AutoGen.BasicSamples/Program.cs index a8bc7e1b015d..51ea95900126 100644 --- a/dotnet/sample/AutoGen.BasicSamples/Program.cs +++ b/dotnet/sample/AutoGen.BasicSamples/Program.cs @@ -1,4 +1,59 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Program.cs -await Example07_Dynamic_GroupChat_Calculate_Fibonacci.RunAsync(); +//await Example07_Dynamic_GroupChat_Calculate_Fibonacci.RunAsync(); + +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>("LM Studio - Function Call", async () => { await Example09_LMStudio_FunctionCall.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(); })); + + +int idx = 1; +Dictionary>> map = new Dictionary>>(); +Console.WriteLine("Available Examples:\n\n"); +foreach (Tuple> sample in allSamples) +{ + map.Add(idx, sample); + Console.WriteLine("{0}. {1}", idx++, sample.Item1); +} + +Console.WriteLine("\n\nEnter your selection:"); + +try +{ + int val = Convert.ToInt32(Console.ReadLine()); + + if (!map.ContainsKey(val)) + { + Console.WriteLine("Invalid choice"); + } + else + { + Console.WriteLine("\nRunning {0}", map[val].Item1); + await map[val].Item2.Invoke(); + } +} +catch +{ + Console.WriteLine("Error encountered, please check your entry and run again"); +} + +