Commit Graph
5 Commits
Author SHA1 Message Date
Abby HarrisonandShawn Callegari 5e4e0edfaa Python: Plan Object Model (#1907)
### Motivation and Context
This PR ports the plan object model found in the .NET SK to Python. This
fundamentally changes the concept of a planner from a `semantic skill`
to a unique type of `SKFunction`. With this model, we can begin
implementing sequential planner and offer much better plan
customization.

**Notes:**
- This PR does not implement plan serialization/deserialization to/from
JSON. There is a huge existing effort to make the Python SK completely
Pydantic enabled, which will bring serialization and deserialization
capability with it.
- This PR does not include ports of `Action Planner` and `Sequential
Planner` to the Plan Object Model (POM). Following PRs will address
this.
- I also added some missing copywrite headers. A future PR will add
headers to any still missing them.
- added a VSCode launch configuration to run the current file with
pytest
- closes #1486 


### Description
- Added file called `plan.py` which is a python port of the Plan.cs file
found in the .NET SK. Note that it does not contain serialization logic
at this time.
- Added new kernel error `FunctionInvokeError` - mirrors the error list
of the .NET SK
- Added tests for Plan creation
- Added tests for Plan execution - both sync and async


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

---------

Co-authored-by: Shawn Callegari <[email protected]>
2023-07-15 01:34:19 +00:00
Abby HarrisonandShawn Callegari 7b3dc2c47f Python: Filter only json content from basic planner execution input (#1496)
### Motivation and Context
Closes #1469 

There are scenarios where the basic_planner prompt results in a valid
plan surrounded by additional text. This renders the plan unable to be
json deserialized. This PR addresses this scenario. Note that it does
NOT address malformed json.

### Description
- added a regex in basic_planner.execute_plan_async that grabs only json
blocks. See screenshot below of it ignoring additional, non-json text.
- Added dependency on `regex` pip package (`re` package does not support
regex recursion)

Co-authored-by: Shawn Callegari <[email protected]>
2023-06-14 17:28:25 -07:00
Richard Edgar e9bb05e990 Python: Correct function name (#1157)
### Motivation and Context
In the Python `BasicPlanner` one of the examples has a 'translate'
function, but doesn't quite reference it correctly in the JSON output.

### Description
The overall approach is to make the various parts of the few-shot
example in the prompt self-consistent.
2023-05-22 13:43:36 -07:00
Pengfei Ni 90f12583d3 python: fix issue of No module named 'semantic_kernel.planning' (#823)
### 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.
-->

python: fix the issue of `No module named 'semantic_kernel.planning'`.

### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

Add __init__ file for the planning package.
2023-05-06 03:29:33 +00:00
224857ebc3 Python: Basic JSON-based Planner implementation (#597)
### Motivation and Context
Many users and customers have expressed interest in having planning
capabilities in Python. This PR seeks to provide a basic version of the
planner so that people can learn and play around with the concepts and
can be comfortable with implementing their own versions.

A Jupyter notebook is included. 

### Description
Most of the logic of the plan can be found under the `PROMPT` in
`basic_planner.py`.

There is a known limitation that this currently doesn't explicit parse
out arguments that are defined in the semantic function prompts, so when
creating the [AVAILABLE FUNCTIONS] string, it just uses the name of the
function and the description.

The execution of the plan also happens from start to finish. There is
currently no support for piecewise execution.

---------

Co-authored-by: Alex Chao <[email protected]>
Co-authored-by: Alex Chao <[email protected]>
Co-authored-by: Abby Harrison <[email protected]>
Co-authored-by: Mark Karle <[email protected]>
2023-05-04 22:04:36 +00:00