-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.Net: Add Flow Orchestrator extension to Semantic Kernel #3023
Conversation
<!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> This PR is trying to help making it easier to build complex Copilot which is capable of commanding, Q&A, collaboration, suggestion, etc, in reliable ways. A new FlowPlanner is introduced, which leverages the available skills, execute the plan in multi-step, multi-pass way, including interaction with users to get clarification on the goal, input for skills/functions, and authorization for actions when needed. More details in #2164. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Major changes * FlowModel * ChatSkill, which is to make the implementation of multi-pass skill easier with built in chat history accessor * FlowExecutor * ReAct engine, which is similar as the StepwisePlanner implementation but more isolated and enriched with chat integration * UnitTests * IntegrationTests * Examples <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Yan Li <[email protected]> Co-authored-by: Lee Miller <[email protected]>
This commit simplifies the GetKernelBuilder method by directly returning the builder with the AzureChatCompletionService configured. It also updates the retry configuration to use the new WithRetryBasic method, removing the need for the HttpRetryConfig object.
…es (#2778) Follow up PR into feature branch for #2164. 1. Merge from main 2. Address code style issues per latest rules 3. Support more step completion types <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
### Motivation and Context Note that this PR is for feature branch only. Changes 1. Support optional completion type 2. Support reference flow as a FlowStep 3. Accommodate latest kernel changes 4. Add more unit tests for the Planner ### Description as above ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Mark Karle <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Shawn Callegari <[email protected]> Co-authored-by: Roger Barreto <[email protected]> Co-authored-by: Mark Wallace <[email protected]> Co-authored-by: Dmytro Struk <[email protected]> Co-authored-by: Eduard van Valkenburg <[email protected]> Co-authored-by: SergeyMenshykh <[email protected]> Co-authored-by: Lisa Harrylock <[email protected]> Co-authored-by: Shay Rojansky <[email protected]> Co-authored-by: Anthony Puppo <[email protected]> Co-authored-by: Weihan Li <[email protected]> Co-authored-by: Jadyn <[email protected]> Co-authored-by: Matthew Bolaños <[email protected]> Co-authored-by: Abby Harrison <[email protected]> Co-authored-by: Weihan Li <[email protected]> Co-authored-by: Gina Triolo <[email protected]> Co-authored-by: Jib <[email protected]>
…/Orchestration.Flow namespace (#3007) This commit renames the FlowPlanner class to FlowOrchestrator and updates all references to it. The example file has also been renamed from `Example57_FlowPlanner.cs` to `Example57_FlowOrchestrator.cs`. The change reflects a more accurate naming for the functionality provided by these classes. Additionally, it moves the SendEmailSkill.cs file to the FlowOrchestrator namespace and updates the namespace accordingly. Minor adjustments are made to the DictionaryExtensions.cs file. The main changes are in the `dotnet/SK-dotnet.sln` and `dotnet/src/Extensions/Experimental/Orchestration.Flow` files. _output_ ```txt Running Example57_FlowOrchestrator... ***************************************************** Flow: FlowOrchestrator_Example_Flow Assistant: ["Please provide a valid email address in the following format: [email protected]"] Answer: The current president of the United States is Joe Biden. His current age divided by 2 is 40. User: my email is bad*email&address Assistant: ["Please provide a valid email address in the following format: [email protected]"] User: my email is [email protected] Assistant: ["Do you want to send it to another email address?"] User: yes Assistant: ["Please provide a valid email address in the following format: [email protected]"] User: I also want to notify [email protected] Assistant: ["Do you want to send it to another email address?"] User: no Assistant: [] Email Address: ["The collected email address is [email protected].","The email address collected is [email protected]."] Email Payload: { "Address": "[\u0022The collected email address is [email protected].\u0022,\u0022The email address collected is [email protected].\u0022]", "Content": "The current president of the United States is Joe Biden. His current age divided by 2 is 40." } Time Taken: 00:01:14.6253040 ***************************************************** ``` ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 ## Summary This pull request renames the FlowPlanner class to FlowOrchestrator and moves it to the Experimental/Orchestration.Flow namespace. It also updates the ReActStep namespace and makes changes to the ReActEngine class to use the new FlowOrchestratorConfig instead of the old FlowPlannerConfig. Additionally, it updates the available functions in the GetAvailableFunctions method and makes other minor changes. ## Changes - Renamed FlowPlanner class to FlowOrchestrator - Moved FlowOrchestrator to Experimental/Orchestration.Flow namespace - Renamed FlowPlannerConfig class to FlowOrchestratorConfig - Moved FlowOrchestratorConfig to Experimental/Orchestration.Flow namespace - Moved FlowSerializer to Experimental/Orchestration.Flow namespace - Moved FlowValidator to Experimental/Orchestration.Flow namespace - Moved CompletionType to Experimental/Orchestration.Flow namespace - Moved FlowStep and Flow to Experimental/Orchestration.Flow namespace - Updated all references to renamed classes - Updated ReActStep namespace - Updated ReActEngine class to use FlowOrchestratorConfig instead of FlowPlannerConfig - Updated available functions in GetAvailableFunctions method - Other minor changes --- *Powered by [Microsoft Semantic Kernel](https://github.com/microsoft/semantic-kernel)*
…iables (#3019) ### Motivation and Context Fix bugs which resulted transient failures of examples and integration tests Adds control variables and extension methods to the Orchestration.Flow execution, improving its flexibility and functionality <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Changes Fix InvokeAction bug in ReAct engine Added control variables to Orchestration.Flow execution Added ExitLoopName and ContinueLoopName variables to Constants.cs Added DefaultValue variable to Constants.cs Added ControlVariables array to Constants.cs Modified FlowExecutor.cs to handle ExitLoopName and ContinueLoopName variables Added ContextVariablesExtensions.cs with IsPromptInput and IsContinueLoop extension methods Updated SKContextExtensions.cs with changes to PromptInput and ContinueLoop methods Updated FlowValidator.cs with new ValidatePassthroughVariables method <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
dotnet/src/Extensions/Experimental/Orchestration.Flow/Execution/FlowExecutor.cs
Fixed
Show fixed
Hide fixed
dotnet/src/Extensions/Experimental/Orchestration.Flow/Execution/FlowExecutor.cs
Fixed
Show fixed
Hide fixed
…e flow planner merge 929 (#3026) ## Summary This pull request includes several updates and refactorings to the Orchestration.Flow extension. The changes include renaming the CollectEmailSkill class to CollectEmailPlugin, renaming the ChatSkillVariables class to ChatPluginVariables, and renaming the globalSkillCollection field to globalPluginCollection in the FlowExecutor class. Additionally, the CheckRepeatStep and CheckStartStep prompt templates have been moved from the Skills folder to the Plugins folder. The SKContextExtensions class has been updated to use ChatPluginVariables instead of ChatSkillVariables and to fix a bug where the wrong variable was being set. The FlowOrchestrator class has been updated to use globalPluginCollection instead of globalSkillCollection, and the FlowOrchestratorConfig class has been updated to rename ExcludedSkills to ExcludedPlugins. The Skills property in the FlowStep class has been replaced with a Plugins property, and the FlowSerializer and FlowValidator classes have been updated to reflect this change. Additionally, the CollectEmailSkill class has been renamed to CollectEmailPlugin, and the ISKFunction.SetDefaultSkillCollection method has been renamed to ISKFunction.SetDefaultFunctionCollection. Finally, an unused test settings file has been removed from the IntegrationTests project. ## Changes - Renamed CollectEmailSkill to CollectEmailPlugin - Renamed ChatSkillVariables to ChatPluginVariables - Renamed globalSkillCollection to globalPluginCollection in FlowExecutor class - Moved CheckRepeatStep and CheckStartStep prompt templates from Skills folder to Plugins folder - Updated SKContextExtensions to use ChatPluginVariables instead of ChatSkillVariables and to fix a bug where the wrong variable was being set - Updated FlowOrchestrator to use globalPluginCollection instead of globalSkillCollection - Updated FlowOrchestratorConfig to rename ExcludedSkills to ExcludedPlugins - Replaced Skills property with Plugins property in FlowStep class - Updated FlowSerializer and FlowValidator classes to use Plugins instead of Skills - Renamed CollectEmailSkill class to CollectEmailPlugin - Renamed ISKFunction.SetDefaultSkillCollection method to ISKFunction.SetDefaultFunctionCollection - Removed unused test settings file from IntegrationTests project --- *Powered by [Microsoft Semantic Kernel](https://github.com/microsoft/semantic-kernel)* ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
Renamed CollectEmailSkill and SendEmailSkill to CollectEmailPlugin and SendEmailPlugin respectively. Updated references in flow.json and flow.yml files. Also, updated the variable name from 'skills' to 'plugins' in FlowOrchestratorTests.cs.
/sk generate-pr-description prefix |
This commit removes the unnecessary project reference to Functions.Semantic from the Experimental.Orchestration.Flow project file.
Replace the usage of Kernel.Builder with the new KernelBuilder class in FlowOrchestratorTests. This change improves code consistency and maintainability.
…rosoft/semantic-kernel into feature-feature-flow-planner
…trator (#3331) ## Summary This pull request updates the EmailPluginV2 in Example60_FlowOrchestrator to prompt for multiple email addresses, adds logging to the orchestrator, and adds new flow control features. The changes include: ## Changes - Updated EmailPluginV2 to prompt for multiple email addresses instead of a single email address - Added logging to Example60_FlowOrchestrator using Microsoft.Extensions.Logging - Changed the 'email_address' variable to 'email_addresses' in CollectEmailAsync - Added a logger factory to GetKernelBuilder to enable logging in the orchestrator - Added a new function to terminate the session, only used when previous attempts failed with FATAL error and need notify user - Added two new extension methods to check if we should terminate flow based on current context and if all variables to be provided with the flow are available in the context - Modified ReActEngine.cs file to append the stop and prompt user function to the available functions if auto-termination is enabled, and to add passthrough data to referenced flow steps - Added EnableAutoTermination property to FlowOrchestratorConfig class - Updated AddPassthrough method in FlowStep class to allow passthrough arguments in referenced flows - Updated skprompt.txt file in ReActEngine plugin to clarify usage instructions --- *Powered by [Microsoft Semantic Kernel](https://github.com/microsoft/semantic-kernel)* ### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Improve performance and reliability for FlowOrchestrator ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few important issues to resolve before this can be merged:
- Fix the example so that it run's in both modes or provide better instructions if I did something wrong. Example numbering does need to be fixed.
- Fix security warnings.
- Isolate all of the new code (see below)
To isolate the code use the following directory structure:
SK-dotnet
├── samples/
└── src/
├── Experimental/
│ ├── Orchestration.Flow
│ ├── Orchestration.Flow.UnitTests
│ └── Orchestration.Flow.IntegrationTests
dotnet/src/Extensions/Experimental/Orchestration.Flow/Experimental.Orchestration.Flow.csproj
Outdated
Show resolved
Hide resolved
dotnet/samples/KernelSyntaxExamples/Example60_FlowOrchestrator.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/KernelSyntaxExamples/Example60_FlowOrchestrator.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/KernelSyntaxExamples/Example60_FlowOrchestrator.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Extensions/Experimental/Orchestration.Flow/Model/FlowStep.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Extensions/Experimental/Orchestration.Flow/Model/FlowStep.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Extensions/Experimental/Orchestration.Flow/Model/FlowStep.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Extensions/Experimental/Orchestration.Flow/Experimental.Orchestration.Flow.csproj
Outdated
Show resolved
Hide resolved
dotnet/src/Extensions/Experimental/Orchestration.Flow/FlowOrchestratorConfig.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Extensions/Experimental/Orchestration.Flow/FlowOrchestratorConfig.cs
Outdated
Show resolved
Hide resolved
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will create issues for any additional code changes that are required
Removed the dependency on BasicPromptTemplateEngine in Example63_FlowOrchestrator.cs and updated ReActEngine.cs to use BasicPromptTemplateFactory instead. Added a project reference to TemplateEngine.Basic in Experimental.Orchestration.Flow.csproj.
Removed the dependency on BasicPromptTemplateEngine in FlowOrchestratorTests.cs and updated the FlowExecutor.cs to use BasicPromptTemplateFactory for creating prompt templates. This change streamlines the code and reduces coupling between components.
) ## Summary This pull request adds the Flow Orchestrator extension to the Semantic Kernel. The Flow Orchestrator extension provides a way to define and execute complex workflows using a YAML-based DSL. The extension includes several new classes and extension methods, as well as a new project file and several new files in the Extensions/Experimental/Orchestration.Flow directory. ## Changes - Added Experimental.Orchestration.Flow.csproj - Added ContextVariablesExtensions.cs - Added FlowExtensions.cs - Added SKContextExtensions.cs - Added new file SKContextExtensions.cs - Added new file FlowOrchestrator.cs - Added new file FlowOrchestratorConfig.cs - Added FlowOrchestratorConfig class to provide configuration options for the ReAct engine used by the Flow orchestrator - Added FlowOrchestrator class to provide a way to define and execute complex workflows using a YAML-based DSL - Added SKContextExtensions class to provide several extension methods for the SKContext class - Added FlowExtensions class to provide extension methods for the Flow class --- *Powered by [Microsoft Semantic Kernel](https://github.com/microsoft/semantic-kernel)* Fixes microsoft#2164 ![image](https://github.com/microsoft/semantic-kernel/assets/35783676/a065e637-c89f-4f2e-986e-629b71ccf81c) ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 - [x] Successful [Integration Tests](https://github.com/microsoft/semantic-kernel/actions/runs/6355696897/job/17264142726) [Integration Tests](https://github.com/microsoft/semantic-kernel/actions/runs/6551142172) @yan-li Co-authored-by: Yan Li [[email protected]](mailto:[email protected]) --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Yan Li <[email protected]> Co-authored-by: Yan Li <[email protected]> Co-authored-by: Mark Karle <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Shawn Callegari <[email protected]> Co-authored-by: Roger Barreto <[email protected]> Co-authored-by: Mark Wallace <[email protected]> Co-authored-by: Dmytro Struk <[email protected]> Co-authored-by: Eduard van Valkenburg <[email protected]> Co-authored-by: SergeyMenshykh <[email protected]> Co-authored-by: Lisa Harrylock <[email protected]> Co-authored-by: Shay Rojansky <[email protected]> Co-authored-by: Anthony Puppo <[email protected]> Co-authored-by: Weihan Li <[email protected]> Co-authored-by: Jadyn <[email protected]> Co-authored-by: Matthew Bolaños <[email protected]> Co-authored-by: Abby Harrison <[email protected]> Co-authored-by: Weihan Li <[email protected]> Co-authored-by: Gina Triolo <[email protected]> Co-authored-by: Jib <[email protected]>
Summary
This pull request adds the Flow Orchestrator extension to the Semantic Kernel. The Flow Orchestrator extension provides a way to define and execute complex workflows using a YAML-based DSL. The extension includes several new classes and extension methods, as well as a new project file and several new files in the Extensions/Experimental/Orchestration.Flow directory.
Changes
Powered by Microsoft Semantic Kernel
Fixes #2164
Contribution Checklist
@yan-li
Co-authored-by: Yan Li [email protected]