Skip to content

Planner: Plan object model #255

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

Merged
merged 10 commits into from
Apr 4, 2023

Conversation

lemillermicrosoft
Copy link
Member

@lemillermicrosoft lemillermicrosoft commented Mar 31, 2023

Motivation and Context

We are working to update Planning to be object based rather than skill based, to help abstract the semantic structure of plans (XML, etc.) away from users into an abstract syntax tree. This will make it so developers do not have to parse and modify XML manually and enable developers to create their own plan and plan generators that can be executed by the kernel.

Description

This changes adds the following classes and interfaces to the SemanticKernel.Planning namespace:

  • Plan: An abstract class that represents a plan for achieving a goal using a semantic kernel.
  • BasePlan: A base class that implements the Plan class with some default properties and methods.
  • PlanStep: A class that represents a single step in a plan, including the description, the selected skill and function, the named parameters, the output and result keys, and the optional children steps.
  • KernelPlanningExtensions: A static class that provides extension methods for running a plan using an IKernel instance.
  • Renames the Plan class to SkillPlan, to avoid confusion with the PlanExecution class and other types of plans in the SemanticKernel namespace

Contribution Checklist

Whats Next

This is the first in a series of PRs to update Planner.

  • Create Plan from a FunctionFlowPlanner and remove PlannerSkill
  • Add additional Planner types and plans

@lemillermicrosoft lemillermicrosoft added the PR: ready for review All feedback addressed, ready for reviews label Mar 31, 2023
@lemillermicrosoft lemillermicrosoft force-pushed the plan_object_model branch 2 times, most recently from 888b734 to 4e97eb4 Compare March 31, 2023 20:00
@lemillermicrosoft lemillermicrosoft enabled auto-merge (squash) March 31, 2023 20:06
shawncal
shawncal previously approved these changes Mar 31, 2023
Copy link
Contributor

@dluc dluc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would refine the structure before going ahead, e.g. Plans are trees of Steps where the root node is a step. The root node step description is also the goal. This approach will allow to find plans with the same logic used to search skills, rather than having two similar things implemented differently.

There is nothing special about the root other than being the root. Classic definition of trees: the root is a Node class like the children using the same Node class (in our case Step)
image

The design needs to enable this:
image

@lemillermicrosoft lemillermicrosoft force-pushed the plan_object_model branch 6 times, most recently from e0e5561 to 8a8ca66 Compare April 1, 2023 03:48
      Summary: This commit renames the Plan class to SkillPlan, to avoid confusion with the PlanExecution class and other types of plans in the SemanticKernel namespace. It also updates all the references to the Plan class in the code, such as variable names, constants, extension methods, and the FromJson method. Additionally, it fixes a reference to the user secrets in the PlannerSkillTests class, which was using the wrong class name, and updates some comments and assertions in the test class to reflect the renaming. This change is part of a larger refactoring effort to improve the clarity and consistency of the planning module.
      Summary: This commit adds the following classes and interfaces to the SemanticKernel.Planning namespace:

      - IPlan: An interface that represents a plan for achieving a goal using a semantic kernel.
      - BasePlan: A base class that implements the IPlan interface with some default properties and methods.
      - PlanStep: A class that represents a single step in a plan, including the description, the selected skill and function, the named parameters, the output and result keys, and the optional children steps.
      - KernelPlanningExtensions: A static class that provides extension methods for running a plan using an IKernel instance.

      These classes and interfaces are intended to facilitate the creation and execution of plans using the semantic kernel framework.
Summary: This commit adds XML documentation comments to the BasePlan, IPlan, PlanStep, and KernelPlanningExtensions classes. The comments provide a brief summary of the purpose and usage of each class, property, and method. The comments also use the <inheritdoc/> tag to avoid duplication of documentation for inherited members. This improves the readability and maintainability of the code.
      Summary: This commit changes the structure and naming of the plan classes to make them more consistent and clear. The main changes are:

      - Remove the Goal property from BasePlan, as it is not used.
      - Rename the State property of BasePlan to match the JSON property name.
      - Rename the Steps property of BasePlan to Root, to indicate that it is the root step of the plan.
      - Rename the Children property of PlanStep to Steps, to indicate that they are sub-steps of the current step.
      - Move the KernelPlanningExtensions class to the Microsoft.SemanticKernel namespace, as it is an extension method for the kernel.
      Summary: This commit simplifies the plan execution logic by changing the IPlan interface to an abstract Plan class, which implements the ISKFunction interface and provides common properties and methods for all plan types. The BasePlan class inherits from the Plan class and overrides the methods defined by the abstract base class. The commit also removes the PlanStep class and the KernelPlanningExtensions class is updated to use the Plan class. This allows for more flexibility and consistency in defining and executing custom plans.
      Summary: This commit renames the RunAsync extension methods in the KernelPlanningExtensions class to StepAsync, to better reflect their functionality of running the next step in a plan asynchronously. The method signatures and documentation comments are also updated accordingly. This change improves the readability and clarity of the code.
      Summary: This commit removes the OutputKey and ResultKey properties from the abstract Plan class, as they are no longer needed for the planning logic. The output and result keys are now handled by the PlanExecutor class, which simplifies the Plan interface and avoids duplication of state variables.
      Summary: This change modifies the Plan class to be an abstract class, as it is only intended to be a base class for other plan types. This makes the design more clear and prevents accidental instantiation of a Plan object. The change also updates the documentation comment of the Plan class to reflect its abstract nature.
      Summary: This commit removes the BasePlan class and moves its logic into the Plan class. The BasePlan class was an abstract class that only provided default implementations for the ISKFunction interface, which are now inherited by the Plan class. This simplifies the class hierarchy and avoids duplication of code.
      Summary: This commit moves the KernelPlanningExtensions class from the Microsoft.SemanticKernel.Planning namespace to the Microsoft.SemanticKernel namespace, to avoid a naming conflict with the Planning namespace in the Microsoft.Orchestration.Planning assembly. This change also simplifies the usage of the extension methods for running plans using a kernel.
@lemillermicrosoft lemillermicrosoft merged commit a6f6b38 into microsoft:main Apr 4, 2023
@shawncal shawncal mentioned this pull request Apr 10, 2023
5 tasks
shawncal added a commit that referenced this pull request Apr 12, 2023
### Motivation and Context
This is the next PR in improving Planning capabilities in the Kernel. It
builds upon previous
#255 to enable
execution of plans and improves the ability to create plans.

### Description
- Rename the Plan class to SKPlan and add support for invoking functions
as part of the plan execution.
- Add a new class for executing plans, and remove the unused PlanRunner
class.
- Add unit and integration tests for the planning functionality and a
test email skill.
- Fix some minor issues and add documentation and comments to the
planning classes and tests.
- Update the VS Code tasks and editor config files to improve the
development experience.
dehoward pushed a commit to lemillermicrosoft/semantic-kernel that referenced this pull request Jun 1, 2023
### Motivation and Context
We are working to update Planning to be object based rather than skill
based, to help abstract the semantic structure of plans (XML, etc.) away
from users into an abstract syntax tree. This will make it so developers
do not have to parse and modify XML manually and enable developers to
create their own plan and plan generators that can be executed by the
kernel.

### Description
This changes adds the following classes and interfaces to the
SemanticKernel.Planning namespace:

- IPlan: An interface that represents a plan for achieving a goal using
a semantic kernel.
- BasePlan: A base class that implements the IPlan interface with some
default properties and methods.
- PlanStep: A class that represents a single step in a plan, including
the description, the selected skill and function, the named parameters,
the output and result keys, and the optional children steps.
- KernelPlanningExtensions: A static class that provides extension
methods for running a plan using an IKernel instance.
- Renames the Plan class to SkillPlan, to avoid confusion with the
PlanExecution class and other types of plans in the SemanticKernel
namespace
dehoward pushed a commit to lemillermicrosoft/semantic-kernel that referenced this pull request Jun 1, 2023
### Motivation and Context
This is the next PR in improving Planning capabilities in the Kernel. It
builds upon previous
microsoft#255 to enable
execution of plans and improves the ability to create plans.

### Description
- Rename the Plan class to SKPlan and add support for invoking functions
as part of the plan execution.
- Add a new class for executing plans, and remove the unused PlanRunner
class.
- Add unit and integration tests for the planning functionality and a
test email skill.
- Fix some minor issues and add documentation and comments to the
planning classes and tests.
- Update the VS Code tasks and editor config files to improve the
development experience.
golden-aries pushed a commit to golden-aries/semantic-kernel that referenced this pull request Oct 10, 2023
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.1.6
to 5.2.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/Microsoft/TypeScript/releases">typescript's
releases</a>.</em></p>
<blockquote>
<h2>TypeScript 5.2</h2>
<p>For release notes, check out the <a
href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/">release
announcement</a>.</p>
<p>For the complete list of fixed issues, check out the</p>
<ul>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.2.0%22+is%3Aclosed+">fixed
issues query for Typescript 5.2.0 (Beta)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.2.1%22+is%3Aclosed+">fixed
issues query for Typescript 5.2.1 (RC)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.2.2%22+is%3Aclosed+">fixed
issues query for Typescript 5.2.2 (Stable)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a
href="https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild">NuGet
package</a></li>
</ul>
<h2>TypeScript 5.2 RC</h2>
<p>For release notes, check out the <a
href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-2-rc/">release
announcement</a>.</p>
<p>For the complete list of fixed issues, check out the</p>
<ul>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.2.0%22+is%3Aclosed+">fixed
issues query for Typescript 5.2.0 (Beta)</a>.</li>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.2.1%22+is%3Aclosed+">fixed
issues query for Typescript 5.2.1 (RC)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a
href="https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild">NuGet
package</a></li>
</ul>
<h2>TypeScript 5.2 Beta</h2>
<p>For release notes, check out the <a
href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-2-beta/">release
announcement</a>.</p>
<p>For the complete list of fixed issues, check out the</p>
<ul>
<li><a
href="https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&amp;q=milestone%3A%22TypeScript+5.2.0%22+is%3Aclosed+">fixed
issues query for Typescript v5.2.0 (Beta)</a>.</li>
</ul>
<p>Downloads are available on <a
href="https://www.npmjs.com/package/typescript">npm</a>.</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/microsoft/TypeScript/commit/9684ba6b0d73c37546ada901e5d0a5324de7fc1d"><code>9684ba6</code></a>
Cherry-pick fix for cross-file inlay hints (<a
href="https://redirect.github.com/Microsoft/TypeScript/issues/55476">#55476</a>)
to <code>release-5.2</code> and LKG ...</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/555ef99d037547da48b8f7e4c629f571b706d1d5"><code>555ef99</code></a>
Bump version to 5.2.2 and LKG</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/6074b9d12b70757fe68ab2b4da059ea363c4df04"><code>6074b9d</code></a>
Update LKG for 5.2.1 RC.</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/b778ed1d8fb9ad3c23c191b78be4835437173de2"><code>b778ed1</code></a>
Merge commit 'e936eb13d2900f21d79553c32a704307c7ad03dd' into
release-5.2</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/10b9962915de5136de972188046a429b02bfed55"><code>10b9962</code></a>
Bump version to 5.2.1-rc and LKG</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/e936eb13d2900f21d79553c32a704307c7ad03dd"><code>e936eb1</code></a>
Update package-lock.json</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/e36cd5768aa46ed2ce9487cce768222d8ee05a4d"><code>e36cd57</code></a>
Update package-lock.json</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/581fba1f6f85116116a5838e44521b4a99de6bad"><code>581fba1</code></a>
Update package-lock.json</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/8fc8c95830fa826eae2441aaa1e83bd2e06c1705"><code>8fc8c95</code></a>
Decorators normative updates (<a
href="https://redirect.github.com/Microsoft/TypeScript/issues/55276">#55276</a>)</li>
<li><a
href="https://github.com/microsoft/TypeScript/commit/b1c4dc475cc0419747c6bec43d12f8e6f64e714c"><code>b1c4dc4</code></a>
Fix class name references (<a
href="https://redirect.github.com/Microsoft/TypeScript/issues/55262">#55262</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/Microsoft/TypeScript/compare/v5.1.6...v5.2.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=typescript&package-manager=npm_and_yarn&previous-version=5.1.6&new-version=5.2.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
johnoliver pushed a commit to johnoliver/semantic-kernel that referenced this pull request Jun 5, 2024
### Motivation and Context
This is the next PR in improving Planning capabilities in the Kernel. It
builds upon previous
microsoft#255 to enable
execution of plans and improves the ability to create plans.

### Description
- Rename the Plan class to SKPlan and add support for invoking functions
as part of the plan execution.
- Add a new class for executing plans, and remove the unused PlanRunner
class.
- Add unit and integration tests for the planning functionality and a
test email skill.
- Fix some minor issues and add documentation and comments to the
planning classes and tests.
- Update the VS Code tasks and editor config files to improve the
development experience.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: ready for review All feedback addressed, ready for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants