A programming framework for agentic AI
increase http retries, add the Dev Improve skill. Experimental.
Ryan Sweet3d0cb7490ca9
diff --git a/cli/Program.cs b/cli/Program.csindex f6da1b116..787c817ce 100644--- a/cli/Program.cs+++ b/cli/Program.cs@@ -6,6 +6,7 @@ using Microsoft.SemanticKernel.Connectors.AI.OpenAI.TextEmbedding;using Microsoft.SemanticKernel.Connectors.Memory.Qdrant;using Microsoft.SemanticKernel.Memory;using Microsoft.SemanticKernel.Orchestration;+using Microsoft.SemanticKernel.Reliability;using skills;class Program@@ -31,7 +32,18 @@ class Program.WithLogger(loggerFactory.CreateLogger<IKernel>()).WithAzureChatCompletionService(kernelSettings.DeploymentOrModelId, kernelSettings.Endpoint, kernelSettings.ApiKey, true, kernelSettings.ServiceId, true).WithMemory(semanticTextMemory)- .WithConfiguration(kernelConfig).Build();+ .WithConfiguration(kernelConfig)+ .Configure(c => c.SetDefaultHttpRetryConfig(new HttpRetryConfig+ {+ MaxRetryCount = 6,+ UseExponentialBackoff = true,+ // MinRetryDelay = TimeSpan.FromSeconds(2),+ // MaxRetryDelay = TimeSpan.FromSeconds(8),+ // MaxTotalRetryTime = TimeSpan.FromSeconds(30),+ // RetryableStatusCodes = new[] { HttpStatusCode.TooManyRequests, HttpStatusCode.RequestTimeout },+ // RetryableExceptions = new[] { typeof(HttpRequestException) }+ }))+ .Build();var fileOption = new Option<FileInfo?>(@@ -93,9 +105,10 @@ class Program(step) => step.subtasks.Select(async (subtask) => {var implementationResult = await CallFunction<string>(nameof(Developer), Developer.Implement, subtask.LLM_prompt, kernel);+ var improvementResult = await CallFunction<string>(nameof(Developer), Developer.Improve, subtask.LLM_prompt, kernel);await sandboxSkill.RunInDotnetAlpineAsync(implementationResult);- await SaveToFile(Path.Combine(outputPath.FullName, $"{step.step}-{subtask.subtask}.sh"), implementationResult);- return implementationResult; }));+ await SaveToFile(Path.Combine(outputPath.FullName, $"{step.step}-{subtask.subtask}.sh"), improvementResult);+ return improvementResult; }));await Task.WhenAll(implementationTasks);}@@ -139,4 +152,4 @@ class Programpublic static class PM { public static string Readme = "Readme"; public static string BootstrapProject = "BootstrapProject"; }public static class DevLead { public static string Plan="Plan"; }-public static class Developer { public static string Implement="Implement"; }\ No newline at end of file+public static class Developer { public static string Implement="Implement"; public static string Improve="Improve";}\ No newline at end of filediff --git a/cli/util/ReactChatAppPrompt.txt b/cli/util/ReactChatAppPrompt.txtnew file mode 100644index 000000000..66e7a0d8d--- /dev/null+++ b/cli/util/ReactChatAppPrompt.txt@@ -0,0 +1,8 @@+I'd like to build a typical Chat Message Applicaton: a simple chat app in React Native that allows the user to manage multiple chat threads.+Each thred is a different conversation. The app can look very similar to Apple iMessage.+Key features of the Chat Message application include the ability to create a new chat thread, view the messages in each thread, and to edite and send a new message.+The frontend for the app will be in typescript and React Native, the backend will be in C# as an Azure Function.+The backend will use a mock function to generate random responses. The backend will store the chats in an Azure CosmosDB.+The application will have a setup for local testing and development that allows testing without deployment to Azure.+Use bicep scripts to create the Azure resources.+The front end should be able to run entirely in the browser.diff --git a/skills/Developer.cs b/skills/Developer.csindex 379d9ab67..5f5cb3a94 100644--- a/skills/Developer.cs+++ b/skills/Developer.cs@@ -21,4 +21,27 @@ public static class Developer {PPenalty = 0.0,FPenalty = 0.0};++ public static SemanticFunctionConfig Improve = new SemanticFunctionConfig+ {+ PromptTemplate = """+ You are a Developer for an application. Your job is to imrove the code that you are given in the input below.+ Please output a new version of code that fixes any problems with this version.+ If there is an error message in the input you should fix that error in the code.+ Wrap the code output up in a bash script that creates the necessary files by overwriting any previous files.+ Do not use any IDE commands and do not build and run the code.+ Make specific choices about implementation. Do not offer a range of options.+ Use comments in the code to describe the intent. Do not include other text other than code and code comments.+ Input: {{$input}}+ {{$wafContext}}+ """,+ Name = nameof(Improve),+ SkillName = nameof(Developer),+ Description = "From a description of a coding task out put the code or scripts necessary to complete the task.",+ MaxTokens = 6500,+ Temperature = 0.0,+ TopP = 0.0,+ PPenalty = 0.0,+ FPenalty = 0.0+ };}diff --git a/skills/SemanticFunctionConfig.cs b/skills/SemanticFunctionConfig.csindex 96bb766db..52f22e363 100644--- a/skills/SemanticFunctionConfig.cs+++ b/skills/SemanticFunctionConfig.cs@@ -18,6 +18,7 @@ public class SemanticFunctionConfig(nameof(PM), nameof(PM.Readme)) => PM.Readme,(nameof(DevLead), nameof(DevLead.Plan)) => DevLead.Plan,(nameof(Developer), nameof(Developer.Implement)) => Developer.Implement,+ (nameof(Developer), nameof(Developer.Improve)) => Developer.Improve,_ => throw new ArgumentException($"Unable to find {skillName}.{functionName}")};}\ No newline at end of file