A programming framework for agentic AI
Semantic Kernel Activity roudtrips when executing workflow but I cant get it to set the result in the workflow context.
Ryan Sweet75283b3f70f0
diff --git a/Elsa.SemanticKernel/Activities/SemanticKernelSkillRequest.cs b/Elsa.SemanticKernel/Activities/SemanticKernelSkillRequest.csindex b31429658..c8027c7d2 100644--- a/Elsa.SemanticKernel/Activities/SemanticKernelSkillRequest.cs+++ b/Elsa.SemanticKernel/Activities/SemanticKernelSkillRequest.cs@@ -19,20 +19,20 @@ using skills;/// <summary>/// Invoke a Semantic Kernel skill./// </summary>-[Activity("Elsa", "SemanticKernelSkill", "Invoke a Semantic Kernel skill. ", DisplayName = "Semantic Kernel Skill", Kind = ActivityKind.Task)]+[Activity("Elsa", "AI Chat", "Invoke a Semantic Kernel skill. ", DisplayName = "Semantic Kernel Skill", Kind = ActivityKind.Task)][PublicAPI]public class SemanticKernelSkill : CodeActivity<string>{[Input(- Description = "System Prompt.",- UIHint = InputUIHints.MultiText,- DefaultValue = new string[0])]- public Input<string> SystemPrompt { get; set; } = default!;+ Description = "System Prompt",+ UIHint = InputUIHints.MultiLine,+ DefaultValue = PromptDefaults.SystemPrompt)]+ public Input<string> SysPrompt { get; set; } = default!;[Input(- Description = "User Input Prompt.",- UIHint = InputUIHints.MultiText,- DefaultValue = new string[0])]+ Description = "User Input Prompt",+ UIHint = InputUIHints.MultiLine,+ DefaultValue = PromptDefaults.UserPrompt)]public Input<string> Prompt { get; set; }[Input(@@ -44,13 +44,13 @@ public class SemanticKernelSkill : CodeActivity<string>[Input(Description = "The skill to invoke from the semantic kernel",UIHint = InputUIHints.SingleLine,- DefaultValue = "PM")]+ DefaultValue = "Chat")]public Input<string> SkillName { get; set; }[Input(Description = "The function to invoke from the skill",UIHint = InputUIHints.SingleLine,- DefaultValue = "README")]+ DefaultValue = "ChatCompletion")]public Input<string> FunctionName { get; set; }/// <inheritdoc />@@ -58,7 +58,7 @@ public class SemanticKernelSkill : CodeActivity<string>{var skillName = SkillName.Get(context);var functionName = FunctionName.Get(context);- var systemPrompt = SystemPrompt.Get(context);+ var systemPrompt = SysPrompt.Get(context);var prompt = Prompt.Get(context);var maxRetries = MaxRetries.Get(context);var result = await ChatCompletion<string>(skillName, functionName, prompt, maxRetries);@@ -114,6 +114,8 @@ public class SemanticKernelSkill : CodeActivity<string>var answer = await kernel.RunAsync(context, function).ConfigureAwait(false);var result = typeof(T) != typeof(string) ? JsonSerializer.Deserialize<T>(answer.ToString()) : (T)(object)answer.ToString();+ //debug output to console+ Console.WriteLine($"Skill: {skillName} Function: {functionName} Prompt: {prompt} Answer: {result}");return result;}}\ No newline at end of filediff --git a/Elsa.SemanticKernel/Config/PromptDefaults.cs b/Elsa.SemanticKernel/Config/PromptDefaults.csnew file mode 100644index 000000000..6f5a16c75--- /dev/null+++ b/Elsa.SemanticKernel/Config/PromptDefaults.cs@@ -0,0 +1,7 @@+internal static class PromptDefaults {+ public const string SystemPrompt = @"You are fulfilling roles on a software development team.+ Provide a response to the following prompt, do not provide any additional output.";++ public const string UserPrompt = @"Let's build a ToDoList Application!";++ }\ No newline at end of filediff --git a/WorkflowsApp/.env b/WorkflowsApp/.envnew file mode 100644index 000000000..059289bb5--- /dev/null+++ b/WorkflowsApp/.env@@ -0,0 +1,7 @@+export EMBEDDINGDEPLOYMENTORMODELID=text-embedding-ada-002+export SERVICEID=gpt-4+export SERVICETYPE=AzureOpenAI+export ENDPOINT=https://lightspeed-team-shared-openai-eastus.openai.azure.com/+export DEPLOYMENTORMODELID=gpt-4+export APIKEY=3a6944607e2048668f61125aff47ba3f+diff --git a/WorkflowsApp/elsa.sqlite.db b/WorkflowsApp/elsa.sqlite.dbindex 4eec189fb..ca2e1dcd4 100644Binary files a/WorkflowsApp/elsa.sqlite.db and b/WorkflowsApp/elsa.sqlite.db differdiff --git a/WorkflowsApp/elsa.sqlite.db-shm b/WorkflowsApp/elsa.sqlite.db-shmnew file mode 100644index 000000000..0a410f0f5Binary files /dev/null and b/WorkflowsApp/elsa.sqlite.db-shm differdiff --git a/WorkflowsApp/elsa.sqlite.db-wal b/WorkflowsApp/elsa.sqlite.db-walnew file mode 100644index 000000000..4d9a8009dBinary files /dev/null and b/WorkflowsApp/elsa.sqlite.db-wal differdiff --git a/skills/Chat.cs b/skills/Chat.csnew file mode 100644index 000000000..049cd3ac3--- /dev/null+++ b/skills/Chat.cs@@ -0,0 +1,21 @@+namespace skills;+public static class Chat+{+ public static SemanticFunctionConfig ChatCompletion = new SemanticFunctionConfig+ {+ PromptTemplate = """+ You are a helpful assistant. Please complete the prompt as instructed in the Input.+ Provide as many references and links as needed to support the accuracy of your answer.+ Input: {{$input}}+ """,+ Name = nameof(ChatCompletion),+ SkillName = nameof(Chat),+ Description = "Use the Model as a Chatbot.",+ MaxTokens = 6500,+ Temperature = 0.0,+ TopP = 0.0,+ PPenalty = 0.0,+ FPenalty = 0.0+ };++}diff --git a/skills/SemanticFunctionConfig.cs b/skills/SemanticFunctionConfig.csindex 52f22e363..d9d3589c1 100644--- a/skills/SemanticFunctionConfig.cs+++ b/skills/SemanticFunctionConfig.cs@@ -14,6 +14,7 @@ public class SemanticFunctionConfigpublic static SemanticFunctionConfig ForSkillAndFunction(string skillName, string functionName) =>(skillName, functionName) switch{+ (nameof(Chat), nameof(Chat.ChatCompletion)) => Chat.ChatCompletion,(nameof(PM), nameof(PM.BootstrapProject)) => PM.BootstrapProject,(nameof(PM), nameof(PM.Readme)) => PM.Readme,(nameof(DevLead), nameof(DevLead.Plan)) => DevLead.Plan,