diff --git a/Elsa.SemanticKernel/Activities/SemanticKernelSkillRequest.cs b/Elsa.SemanticKernel/Activities/SemanticKernelSkillRequest.cs index b31429658..c8027c7d2 100644 --- a/Elsa.SemanticKernel/Activities/SemanticKernelSkillRequest.cs +++ b/Elsa.SemanticKernel/Activities/SemanticKernelSkillRequest.cs @@ -19,20 +19,20 @@ using skills; /// /// Invoke a Semantic Kernel skill. /// -[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 { [Input( - Description = "System Prompt.", - UIHint = InputUIHints.MultiText, - DefaultValue = new string[0])] - public Input SystemPrompt { get; set; } = default!; + Description = "System Prompt", + UIHint = InputUIHints.MultiLine, + DefaultValue = PromptDefaults.SystemPrompt)] + public Input 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 Prompt { get; set; } [Input( @@ -44,13 +44,13 @@ public class SemanticKernelSkill : CodeActivity [Input( Description = "The skill to invoke from the semantic kernel", UIHint = InputUIHints.SingleLine, - DefaultValue = "PM")] + DefaultValue = "Chat")] public Input SkillName { get; set; } [Input( Description = "The function to invoke from the skill", UIHint = InputUIHints.SingleLine, - DefaultValue = "README")] + DefaultValue = "ChatCompletion")] public Input FunctionName { get; set; } /// @@ -58,7 +58,7 @@ public class SemanticKernelSkill : CodeActivity { 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(skillName, functionName, prompt, maxRetries); @@ -114,6 +114,8 @@ public class SemanticKernelSkill : CodeActivity var answer = await kernel.RunAsync(context, function).ConfigureAwait(false); var result = typeof(T) != typeof(string) ? JsonSerializer.Deserialize(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 file diff --git a/Elsa.SemanticKernel/Config/PromptDefaults.cs b/Elsa.SemanticKernel/Config/PromptDefaults.cs new file mode 100644 index 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 file diff --git a/WorkflowsApp/.env b/WorkflowsApp/.env new file mode 100644 index 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.db index 4eec189fb..ca2e1dcd4 100644 Binary files a/WorkflowsApp/elsa.sqlite.db and b/WorkflowsApp/elsa.sqlite.db differ diff --git a/WorkflowsApp/elsa.sqlite.db-shm b/WorkflowsApp/elsa.sqlite.db-shm new file mode 100644 index 000000000..0a410f0f5 Binary files /dev/null and b/WorkflowsApp/elsa.sqlite.db-shm differ diff --git a/WorkflowsApp/elsa.sqlite.db-wal b/WorkflowsApp/elsa.sqlite.db-wal new file mode 100644 index 000000000..4d9a8009d Binary files /dev/null and b/WorkflowsApp/elsa.sqlite.db-wal differ diff --git a/skills/Chat.cs b/skills/Chat.cs new file mode 100644 index 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.cs index 52f22e363..d9d3589c1 100644 --- a/skills/SemanticFunctionConfig.cs +++ b/skills/SemanticFunctionConfig.cs @@ -14,6 +14,7 @@ public class SemanticFunctionConfig public 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,