A programming framework for agentic AI
update compiles
Kosta Petand18296f80015
diff --git a/src/apps/cli/Program.cs b/src/apps/cli/Program.csindex 5d18ee5b1..4b5ab7dac 100644--- a/src/apps/cli/Program.cs+++ b/src/apps/cli/Program.cs@@ -154,10 +154,8 @@ class Program{wafContext += $"\n {memory.Metadata.Text}";}- var skillConfig = SemanticFunctionConfig.ForSkillAndFunction(skillName, functionName);- var function = kernel.CreateSemanticFunction(skillConfig.PromptTemplate, skillConfig.Name, skillConfig.SkillName,- skillConfig.Description, skillConfig.MaxTokens, skillConfig.Temperature,- skillConfig.TopP, skillConfig.PPenalty, skillConfig.FPenalty);+ var promptTemplate = Skills.ForSkillAndFunction(skillName, functionName);+ var function = kernel.CreateSemanticFunction(promptTemplate);var context = new ContextVariables();context.Set("input", input);diff --git a/src/apps/gh-flow-df/Services/WebHookEventProcessor.cs b/src/apps/gh-flow-df/Services/WebHookEventProcessor.csindex ab7a43a51..f2d25a05b 100644--- a/src/apps/gh-flow-df/Services/WebHookEventProcessor.cs+++ b/src/apps/gh-flow-df/Services/WebHookEventProcessor.cs@@ -97,8 +97,8 @@ public class SKWebHookEventProcessor : WebhookEventProcessorprivate async Task<string> RunSkill(string skillName, string functionName, string input){- var prompt = ForSkillAndFunction(skillName, functionName);- var function = _kernel.CreateSemanticFunction(prompt, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });+ var prompt = Skills.ForSkillAndFunction(skillName, functionName);+ var function = _kernel.CreateSemanticFunction(prompt, new OpenAIRequestSettings { MaxTokens = 8000, Temperature = 0.4, TopP = 1 });var interestingMemories = _kernel.Memory.SearchAsync("waf-pages", input, 2);var wafContext = "Consider the following architectural guidelines:";@@ -114,15 +114,4 @@ public class SKWebHookEventProcessor : WebhookEventProcessorvar result = await _kernel.RunAsync(context, function);return result.ToString();}-- private static string ForSkillAndFunction(string skillName, string functionName) =>- (skillName, functionName) switch- {- (nameof(PM), nameof(PM.BootstrapProject)) => PM.BootstrapProject,- (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 filediff --git a/src/libs/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs b/src/libs/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.csindex bc5fcc754..df2e56235 100644--- a/src/libs/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs+++ b/src/libs/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs@@ -8,8 +8,10 @@ using Elsa.Extensions;using Elsa.Workflows.Core;using Elsa.Workflows.Core.Contracts;using Elsa.Workflows.Core.Models;+using Microsoft.AI.DevTeam.Skills;using Microsoft.Extensions.Logging;using Microsoft.SemanticKernel;+using Microsoft.SemanticKernel.Connectors.AI.OpenAI;using Microsoft.SemanticKernel.Orchestration;namespace Elsa.SemanticKernel;@@ -164,19 +166,11 @@ public class SemanticKernelActivityProvider : IActivityProviderstring field = function.FieldType.ToString();if (field.Equals("Microsoft.SKDevTeam.SemanticFunctionConfig")){- var skillConfig = SemanticFunctionConfig.ForSkillAndFunction(skillType.Name, function.Name);+ var promptTemplate = Skills.ForSkillAndFunction(skillType.Name, function.Name);var skfunc = kernel.CreateSemanticFunction(- skillConfig.PromptTemplate,- skillConfig.Name,- skillConfig.SkillName,- skillConfig.Description,- skillConfig.MaxTokens,- skillConfig.Temperature,- skillConfig.TopP,- skillConfig.PPenalty,- skillConfig.FPenalty);-- Console.WriteLine($"SKActivityProvider Added SK function: {skfunc.SkillName}.{skfunc.Name}");+ promptTemplate, new OpenAIRequestSettings { MaxTokens = 8000, Temperature = 0.4, TopP = 1 });++ Console.WriteLine($"SKActivityProvider Added SK function: {skfunc.PluginName}.{skfunc.Name}");}}}diff --git a/src/libs/Elsa.SemanticKernel/Activities/SemanticKernel.cs b/src/libs/Elsa.SemanticKernel/Activities/SemanticKernel.csindex 409725377..e81da076b 100644--- a/src/libs/Elsa.SemanticKernel/Activities/SemanticKernel.cs+++ b/src/libs/Elsa.SemanticKernel/Activities/SemanticKernel.cs@@ -86,9 +86,9 @@ public class SemanticKernelSkill : CodeActivity<string>var kernel = KernelBuilder();// load the skill- var promptTemplate = ForSkillAndFunction(skillName, functionName);+ var promptTemplate = Skills.ForSkillAndFunction(skillName, functionName);- var function = kernel.CreateSemanticFunction(promptTemplate, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });+ var function = kernel.CreateSemanticFunction(promptTemplate, new OpenAIRequestSettings { MaxTokens = 8000, Temperature = 0.4, TopP = 1 });// set the context (our prompt)var contextVars = new ContextVariables();@@ -151,17 +151,6 @@ public class SemanticKernelSkill : CodeActivity<string>return list.ToString();}- private static string ForSkillAndFunction(string skillName, string functionName) =>- (skillName, functionName) switch- {- (nameof(PM), nameof(PM.BootstrapProject)) => PM.BootstrapProject,- (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}")- };-/// <summary>/// Gets a semantic kernel instance/// </summary>@@ -209,9 +198,9 @@ public class SemanticKernelSkill : CodeActivity<string>string field = function.FieldType.ToString();if (field.Equals("Microsoft.SKDevTeam.SemanticFunctionConfig")){- var prompt = ForSkillAndFunction(skillType.Name, function.Name);+ var prompt = Skills.ForSkillAndFunction(skillType.Name, function.Name);var skfunc = kernel.CreateSemanticFunction(- prompt, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });+ prompt, new OpenAIRequestSettings { MaxTokens = 8000, Temperature = 0.4, TopP = 1 });Console.WriteLine($"SK Added function: {skfunc.SkillName}.{skfunc.Name}");}diff --git a/src/libs/Microsoft.AI.DevTeam.Skills/Extensions.cs b/src/libs/Microsoft.AI.DevTeam.Skills/Extensions.csnew file mode 100644index 000000000..b77b45813--- /dev/null+++ b/src/libs/Microsoft.AI.DevTeam.Skills/Extensions.cs@@ -0,0 +1,24 @@+namespace Microsoft.AI.DevTeam.Skills;++public static class Skills+{+ public static string ForSkillAndFunction(string skillName, string functionName) =>+ (skillName, functionName) switch+ {+ (nameof(PM), nameof(PM.BootstrapProject)) => PM.BootstrapProject,+ (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}")+ };+}++public interface IFunction+{+ string Name { get; }+ string Description { get; }+ string PluginName { get; }+ string DefaultValue { get; }+ string[] Parameters { get; }+}diff --git a/src/libs/Microsoft.AI.DevTeam/Actors/DevLead/DeveloperLead.cs b/src/libs/Microsoft.AI.DevTeam/Actors/DevLead/DeveloperLead.csindex c77885e05..a86f18ef7 100644--- a/src/libs/Microsoft.AI.DevTeam/Actors/DevLead/DeveloperLead.cs+++ b/src/libs/Microsoft.AI.DevTeam/Actors/DevLead/DeveloperLead.cs@@ -23,7 +23,7 @@ public class DeveloperLead : SemanticPersona, ILeadDevelopment// var review = architect.ReviewPlan(plan);// return Task.FromResult(plan);- var function = _kernel.CreateSemanticFunction(DevLead.Plan, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });+ var function = _kernel.CreateSemanticFunction(DevLead.Plan, new OpenAIRequestSettings { MaxTokens = 15000, Temperature = 0.4, TopP = 1 });var context = new ContextVariables();context.Set("input", ask);if (_state.State.History == null) _state.State.History = new List<ChatHistoryItem>();diff --git a/src/libs/Microsoft.AI.DevTeam/Actors/Developer/Developer.cs b/src/libs/Microsoft.AI.DevTeam/Actors/Developer/Developer.csindex 83a488685..0b4e01760 100644--- a/src/libs/Microsoft.AI.DevTeam/Actors/Developer/Developer.cs+++ b/src/libs/Microsoft.AI.DevTeam/Actors/Developer/Developer.cs@@ -18,7 +18,7 @@ public class Dev : SemanticPersona, IDevelopCodepublic async Task<string> GenerateCode(string ask){- var function = _kernel.CreateSemanticFunction(Developer.Implement, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });+ var function = _kernel.CreateSemanticFunction(Developer.Implement, new OpenAIRequestSettings { MaxTokens = 15000, Temperature = 0.8, TopP = 1 });var context = new ContextVariables();if (_state.State.History == null) _state.State.History = new List<ChatHistoryItem>();_state.State.History.Add(new ChatHistoryItemdiff --git a/src/libs/Microsoft.AI.DevTeam/Actors/ProductManager/ProductManager.cs b/src/libs/Microsoft.AI.DevTeam/Actors/ProductManager/ProductManager.csindex 970fbc650..bb93e1e80 100644--- a/src/libs/Microsoft.AI.DevTeam/Actors/ProductManager/ProductManager.cs+++ b/src/libs/Microsoft.AI.DevTeam/Actors/ProductManager/ProductManager.cs@@ -16,7 +16,7 @@ public class ProductManager : SemanticPersona, IManageProduct}public async Task<string> CreateReadme(string ask){- var function = _kernel.CreateSemanticFunction(PM.Readme, new OpenAIRequestSettings { MaxTokens = 100, Temperature = 0.4, TopP = 1 });+ var function = _kernel.CreateSemanticFunction(PM.Readme, new OpenAIRequestSettings { MaxTokens = 10000, Temperature = 0.6, TopP = 1 });var context = new ContextVariables();context.Set("input", ask);if(_state.State.History == null) _state.State.History = new List<ChatHistoryItem>();