From 7b52b5286f3be6e2ca452bf7c5d2e6598c3ca12b Mon Sep 17 00:00:00 2001 From: Ryan Sweet Date: Tue, 18 Jul 2023 08:50:22 -0700 Subject: [PATCH] update Readme, fix activity provider context --- .../SemanticKernelSkillActivityProvider.cs | 4 +-- .../Activities/SemanticKernel.cs | 2 +- README.md | 36 +++++++++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs b/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs index 7ffaa1cb9..6acf2e9c0 100644 --- a/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs +++ b/Elsa.SemanticKernel/Activities/ActivityProviders/SemanticKernelSkillActivityProvider.cs @@ -50,7 +50,7 @@ public class SemanticKernelActivityProvider : IActivityProvider // get a list of skills in the assembly var skills = LoadSkillsFromAssemblyAsync("skills", kernel); - SKContext context = new SKContext(); + SKContext context = kernel.CreateNewContext(); var functionsAvailable = context.Skills.GetFunctionsView(); // create activity descriptors for each skilland function @@ -195,7 +195,7 @@ public class SemanticKernelActivityProvider : IActivityProvider skillConfig.PPenalty, skillConfig.FPenalty); - Console.WriteLine($"SK Added function: {skfunc.SkillName}.{skfunc.Name}"); + Console.WriteLine($"SKActivityProvider Added SK function: {skfunc.SkillName}.{skfunc.Name}"); } } } diff --git a/Elsa.SemanticKernel/Activities/SemanticKernel.cs b/Elsa.SemanticKernel/Activities/SemanticKernel.cs index f8b6dcbe7..d92fe2822 100644 --- a/Elsa.SemanticKernel/Activities/SemanticKernel.cs +++ b/Elsa.SemanticKernel/Activities/SemanticKernel.cs @@ -29,7 +29,7 @@ namespace Elsa.SemanticKernel; /// /// Invoke a Semantic Kernel skill. /// -[Activity("Elsa", "AI Chat", "Invoke a Semantic Kernel skill. ", DisplayName = "Semantic Kernel Skill", Kind = ActivityKind.Task)] +[Activity("Elsa", "Semantic Kernel", "Invoke a Semantic Kernel skill. ", DisplayName = "Generic Semantic Kernel Skill", Kind = ActivityKind.Task)] [PublicAPI] public class SemanticKernelSkill : CodeActivity { diff --git a/README.md b/README.md index 4e01b8e0e..730687f1f 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,11 @@ This is a nascent project - we will use the README to describe the project's int ## Trying it out -## Via Workflows +### Elsa.SemanticKernel -The project supports running Semantic Kernel Skills as workflows using [Elsa Workflows](https://v3.elsaworkflows.io). You can build the workflows as .NET code or in the visual designer. +SemanticKernel Activity Provider for Elsa Workflows 3.x + +The project supports running [Microsoft Semantic Kernel](https://github.com/microsoft/semantic-kernel) Skills as workflows using [Elsa Workflows](https://v3.elsaworkflows.io). You can build the workflows as .NET code or in the visual designer. To run the designer: ```bash @@ -24,8 +26,38 @@ To run the designer: # Open browser to the URI in the console output ``` +By Default you can use "admin" and "password" to login. Please review [Workflow Security](https://v3.elsaworkflows.io/docs/installation/aspnet-apps-workflow-server) for into on securing the app, using API tokens, and more. + +To [invoke](https://v3.elsaworkflows.io/docs/guides/invoking-workflows) a workflow, first it must be "Published". If your workflow has a trigger activity, you can use that. When your workflow is ready, click the "Publish" button. You can also execute the workflow using the API. Then, find the Workflow Definition ID. From a command line, you can use "curl": + +```bash +> curl --location 'https://localhost:5001/elsa/api/workflow-definitions/{workflow_definition_id}/execute' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: ApiKey {api_key}' \ +--data '{ +}' +``` + Once you have the app runing locally, you can login (admin/password - see the [Elsa Workflows](https://v3.elsaworkflows.io) for info about securing). Then you can click "new workflow" to begin building your workflow with semantic kernel skills. +1. Drag workflow Activity blocks into the designer, and examine the settings. +2. Connect the Activities to specify an order of operations. +3. You can use Workfflow Variables to pass state between activities. + 1. Create a Workflow Variable, "MyVariable" + 2. Click on the Activity that you want to use to populate the variable. + 3. In the Settings box for the Activity, Click "Output" + 4. Set the "Output" to the variable chosen. + 5. Click the Activity that will use the variable. Click on "Settings". + 6. Find the text box representing the variable that you want to populate, in this case usually "input". + 7. Click the "..." widget above the text box, and select "javascript" + 8. Set the value of the text box to + + ```javascript + `${getMyVariable()}` + ``` + + 9. Run the workflow. + ## Via CLI The easiest way to run the project is in Codespaces. Codespaces will start a qdrant instance for you.