Skip to content
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: Document how to use remote plugin manifests with Semantic Kernel #1728

Closed
1 of 5 tasks
lemillermicrosoft opened this issue Jun 27, 2023 · 2 comments
Closed
1 of 5 tasks
Labels
auto-closed Automatically closed

Comments

@lemillermicrosoft
Copy link
Member

lemillermicrosoft commented Jun 27, 2023

Kernel should be able to execute plugins that are not registered in the kernel but are pulled dynamically from a vector store.

Developers do not always have access to the kernel code or access to change it. Plugin developers will need to be able to create their plugins and deploy those. After they do that, they will use the manifest file with the description in it to store into a centralized location. This location will need to be fast to query and retrieve plugins that will help solve the ask.

Tasks

@lemillermicrosoft lemillermicrosoft self-assigned this Jun 27, 2023
@lemillermicrosoft lemillermicrosoft converted this from a draft issue Jun 27, 2023
@evchaki evchaki added sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community) kernel Issues or pull requests impacting the core kernel labels Jun 27, 2023
@lemillermicrosoft lemillermicrosoft added this to the Sprint 37 milestone Jun 27, 2023
github-merge-queue bot pushed a commit that referenced this issue Jun 27, 2023
### Motivation and Context
This change is part of a need to enable planners that can reference a
large list of potential plugins that aren't loaded in a kernel instance.
Additionally, consumers of planners need to be able to load plugins on
demand when needed by a plan. The change includes some additional
improvements to the sequential plan parser and prompt.

Part of #1728 

### Description
This pull request refactors and improves the sequential plan parser and
config, simplifying the code, adding new features, and fixing some
issues. The main changes are:

- Use the Azure Chat Completion Service instead of the Azure Text
Completion Service for the sequential planner, and lower the relevancy
threshold for creating a plan. This allows for more flexibility and
creativity in generating plans, and improves the performance and
accuracy of the planner.
- Refactor the plan parsing logic to simplify the code and improve
readability. Remove unnecessary try-catch blocks, logging statements,
and string splitting logic. Reorder the parameters of the ToPlanFromXml
method to match the order of the XML attributes. Ignore text and comment
nodes in the plan XML, as they are not valid steps and could cause
confusion or errors. Remove the logic that adds empty nodes as steps, as
they are not valid functions and could cause errors or confusion.
- Add two optional functions to the SequentialPlannerConfig class that
allow the planner to use custom logic for getting available functions
and finding functions by name. These functions can be useful for
scenarios where the planner needs to access functions from different
sources or with different criteria, such as filtering by skill category
or function type. The default behavior of the planner remains unchanged
if these functions are not specified.
- Simplify and standardize the syntax for calling functions in the plan
XML, using fully qualified function names and consistent attribute names
for inputs, outputs, and parameters. Update the skprompt.txt file to
reflect the new syntax and add more instructions and examples for
creating a plan. Update the sequential plan parser tests to use the new
syntax and function names, and add a helper method to get the function
from the kernel context.
- Fix some minor typos and errors in the code and the skprompt.txt file.

Details:

-
dotnet/src/IntegrationTests/Planning/SequentialPlanner/SequentialPlannerTests.cs
- Changed the KernelSyntaxExamples and SequentialPlannerTests to use the
Azure Chat Completion Service instead of the Azure Text Completion
Service, by replacing the deployment name, endpoint, and key environment
variables.
- Removed the EmailSkillFake import from the InitializeKernel method, as
it is not used in any test case and is already imported in the
TestHelpers class.
- Updated the tests to reflect the changes in the plan parser and remove
the redundant or invalid steps. For example, remove the text and empty
nodes from the plan XML, and update the expected number and description
of the steps.
-
dotnet/src/Extensions/Planning.SequentialPlanner/SequentialPlanParser.cs
- Simplified the ToPlanFromXml method by removing unnecessary try-catch
blocks, logging statements, and string splitting logic.
- Reordered the parameters of the ToPlanFromXml method to match the
order of the XML attributes, as this makes the code more consistent and
easier to read.
- Ignored text and comment nodes in the plan XML, as they are not valid
steps and could cause confusion or errors. Added TODO comments for
possible future enhancements using text or comments as reasoning or
desired functions.
- Removed the logic that adds empty nodes as steps, as they are not
valid functions and could cause errors or confusion. Added TODO comments
for possible future enhancements using empty nodes as desired functions.
- Added a GetFunction parameter to the ToPlanFromXml method that takes a
delegate for finding a skill function by skill name and function name.
This delegate can be specified in the SequentialPlannerConfig class or
default to the existing logic of using the SKContext.
- Added a new static method GetFunction to the SequentialPlanParser
class that returns the default delegate for getting the ISKFunction
instance, which calls context.Skills.TryGetFunction.
- Fixed a minor typo in the GetFunctionName method, changing
"functionName" to "functionNameAttribute". This makes the code more
accurate and clear.
-
dotnet/src/Extensions/Planning.SequentialPlanner/SequentialPlannerConfig.cs
- Added a new property GetAvailableFunctionsAsync to the
SequentialPlannerConfig class that takes a delegate of type
Func<SequentialPlannerConfig, string,
Task<IOrderedEnumerable<FunctionView>>>. This delegate can be used to
provide a custom logic for retrieving available functions from a
semantic query, instead of using the default logic that calls
context.GetAvailableFunctionsAsync. The default value of this property
is null, which means the default logic will be used.
- Modified the SKContextSequentialPlannerExtensions class to use the
GetAvailableFunctionsAsync delegate if it is not null, otherwise fall
back to the default logic.
- dotnet/src/Extensions/Planning.SequentialPlanner/skprompt.txt
- Simplified and standardized the syntax for calling functions from
<function.{FunctionName} ... /> to
<function.{FullyQualifiedFunctionName} ... />, where
{FullyQualifiedFunctionName} is the name of the function with its
namespace or skill prefix, such as _GLOBAL_FUNCTIONS_.NovelOutline or
AuthorAbility.Summarize.


### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows SK Contribution Guidelines
(https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [x] The code follows the .NET coding conventions
(https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions)
verified with `dotnet format`
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
shawncal pushed a commit to shawncal/semantic-kernel that referenced this issue Jul 6, 2023
…soft#1727)

### Motivation and Context
This change is part of a need to enable planners that can reference a
large list of potential plugins that aren't loaded in a kernel instance.
Additionally, consumers of planners need to be able to load plugins on
demand when needed by a plan. The change includes some additional
improvements to the sequential plan parser and prompt.

Part of microsoft#1728 

### Description
This pull request refactors and improves the sequential plan parser and
config, simplifying the code, adding new features, and fixing some
issues. The main changes are:

- Use the Azure Chat Completion Service instead of the Azure Text
Completion Service for the sequential planner, and lower the relevancy
threshold for creating a plan. This allows for more flexibility and
creativity in generating plans, and improves the performance and
accuracy of the planner.
- Refactor the plan parsing logic to simplify the code and improve
readability. Remove unnecessary try-catch blocks, logging statements,
and string splitting logic. Reorder the parameters of the ToPlanFromXml
method to match the order of the XML attributes. Ignore text and comment
nodes in the plan XML, as they are not valid steps and could cause
confusion or errors. Remove the logic that adds empty nodes as steps, as
they are not valid functions and could cause errors or confusion.
- Add two optional functions to the SequentialPlannerConfig class that
allow the planner to use custom logic for getting available functions
and finding functions by name. These functions can be useful for
scenarios where the planner needs to access functions from different
sources or with different criteria, such as filtering by skill category
or function type. The default behavior of the planner remains unchanged
if these functions are not specified.
- Simplify and standardize the syntax for calling functions in the plan
XML, using fully qualified function names and consistent attribute names
for inputs, outputs, and parameters. Update the skprompt.txt file to
reflect the new syntax and add more instructions and examples for
creating a plan. Update the sequential plan parser tests to use the new
syntax and function names, and add a helper method to get the function
from the kernel context.
- Fix some minor typos and errors in the code and the skprompt.txt file.

Details:

-
dotnet/src/IntegrationTests/Planning/SequentialPlanner/SequentialPlannerTests.cs
- Changed the KernelSyntaxExamples and SequentialPlannerTests to use the
Azure Chat Completion Service instead of the Azure Text Completion
Service, by replacing the deployment name, endpoint, and key environment
variables.
- Removed the EmailSkillFake import from the InitializeKernel method, as
it is not used in any test case and is already imported in the
TestHelpers class.
- Updated the tests to reflect the changes in the plan parser and remove
the redundant or invalid steps. For example, remove the text and empty
nodes from the plan XML, and update the expected number and description
of the steps.
-
dotnet/src/Extensions/Planning.SequentialPlanner/SequentialPlanParser.cs
- Simplified the ToPlanFromXml method by removing unnecessary try-catch
blocks, logging statements, and string splitting logic.
- Reordered the parameters of the ToPlanFromXml method to match the
order of the XML attributes, as this makes the code more consistent and
easier to read.
- Ignored text and comment nodes in the plan XML, as they are not valid
steps and could cause confusion or errors. Added TODO comments for
possible future enhancements using text or comments as reasoning or
desired functions.
- Removed the logic that adds empty nodes as steps, as they are not
valid functions and could cause errors or confusion. Added TODO comments
for possible future enhancements using empty nodes as desired functions.
- Added a GetFunction parameter to the ToPlanFromXml method that takes a
delegate for finding a skill function by skill name and function name.
This delegate can be specified in the SequentialPlannerConfig class or
default to the existing logic of using the SKContext.
- Added a new static method GetFunction to the SequentialPlanParser
class that returns the default delegate for getting the ISKFunction
instance, which calls context.Skills.TryGetFunction.
- Fixed a minor typo in the GetFunctionName method, changing
"functionName" to "functionNameAttribute". This makes the code more
accurate and clear.
-
dotnet/src/Extensions/Planning.SequentialPlanner/SequentialPlannerConfig.cs
- Added a new property GetAvailableFunctionsAsync to the
SequentialPlannerConfig class that takes a delegate of type
Func<SequentialPlannerConfig, string,
Task<IOrderedEnumerable<FunctionView>>>. This delegate can be used to
provide a custom logic for retrieving available functions from a
semantic query, instead of using the default logic that calls
context.GetAvailableFunctionsAsync. The default value of this property
is null, which means the default logic will be used.
- Modified the SKContextSequentialPlannerExtensions class to use the
GetAvailableFunctionsAsync delegate if it is not null, otherwise fall
back to the default logic.
- dotnet/src/Extensions/Planning.SequentialPlanner/skprompt.txt
- Simplified and standardized the syntax for calling functions from
<function.{FunctionName} ... /> to
<function.{FullyQualifiedFunctionName} ... />, where
{FullyQualifiedFunctionName} is the name of the function with its
namespace or skill prefix, such as _GLOBAL_FUNCTIONS_.NovelOutline or
AuthorAbility.Summarize.


### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows SK Contribution Guidelines
(https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [x] The code follows the .NET coding conventions
(https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions)
verified with `dotnet format`
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
@lemillermicrosoft lemillermicrosoft moved this from Sprint: In Progress to Sprint: Planned in Semantic Kernel Aug 23, 2023
@lemillermicrosoft lemillermicrosoft moved this from Sprint: Planned to Backlog - Plugins in Semantic Kernel Aug 25, 2023
@matthewbolanos matthewbolanos removed this from the v1.0.0 milestone Oct 12, 2023
@matthewbolanos matthewbolanos removed their assignment Nov 28, 2023
@github-project-automation github-project-automation bot moved this from Backlog - Plugins to Sprint: Done in Semantic Kernel Nov 28, 2023
@matthewbolanos matthewbolanos moved this from Sprint: Done to Backlog in Semantic Kernel Nov 28, 2023
@matthewbolanos matthewbolanos added the docs and tests Improvements or additions to documentation label Jan 2, 2024
@matthewbolanos
Copy link
Member

We'll first start by adding documentation that shows how to do this today.

@matthewbolanos matthewbolanos changed the title Kernel support for remote plugin manifest Document how to use remote plugin manifests with Semantic Kernel Jan 2, 2024
@matthewbolanos matthewbolanos added .NET Issue or Pull requests regarding .NET code and removed kernel Issues or pull requests impacting the core kernel labels Jan 2, 2024
@github-actions github-actions bot changed the title Document how to use remote plugin manifests with Semantic Kernel .Net: Document how to use remote plugin manifests with Semantic Kernel Jan 2, 2024
@markwallace-microsoft
Copy link
Member

All .Net issues prior to 1-Dec-2023 are being closed. Please re-open, if this issue is still relevant to the .Net Semantic Kernel 1.x release. In the future all issues that are inactive for more than 90 days will be labelled as 'stale' and closed 14 days later.

@markwallace-microsoft markwallace-microsoft added auto-closed Automatically closed and removed docs and tests Improvements or additions to documentation .NET Issue or Pull requests regarding .NET code sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community) labels Mar 12, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Sprint: Done in Semantic Kernel Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-closed Automatically closed
Projects
Archived in project
Development

No branches or pull requests

6 participants