Skip to content

.Net: Update Sequential Planner example with plan recall#2365

Merged
lemillermicrosoft merged 11 commits intomicrosoft:mainfrom
lemillermicrosoft:808_plan_restore_sample
Aug 16, 2023
Merged

.Net: Update Sequential Planner example with plan recall#2365
lemillermicrosoft merged 11 commits intomicrosoft:mainfrom
lemillermicrosoft:808_plan_restore_sample

Conversation

@lemillermicrosoft
Copy link
Member

@lemillermicrosoft lemillermicrosoft commented Aug 8, 2023

This commit updates the Sequential Planner example to include a new feature that demonstrates how to save and recall a plan for future use. It also refactors some code to improve readability and maintainability, such as extracting methods for initializing the kernel with memory and retrieving the memory store.

Resolves #2343

Example Output

======== Sequential Planner - Create and Execute Email Plan ========
Original plan:
 Goal: Summarize an input, translate to french, and e-mail to John Doe

 Steps:
  - SummarizeSkill.Summarize INPUT='$INPUT' => SUMMARIZED_TEXT
  - WriterSkill.Translate input='$SUMMARIZED_TEXT' language='French' => FRENCH_SUMMARY
  - email.GetEmailAddress INPUT='John Doe' => JOHN_DOE_EMAIL
  - email.SendEmail email_address='$JOHN_DOE_EMAIL' INPUT='$FRENCH_SUMMARY'
Step 1 - Results so far:
In a distant kingdom, King Arjun ruled fairly, but a dragon terrorized his people. Archer Mira offered help, killed the dragon with one shot, and married Arjun. They ruled together, living happily ever after, with Mira remembered as their savior.
Step 2 - Results so far:
Dans un royaume lointain, le roi Arjun régnait de manière juste, mais un dragon terrorisait son peuple. L'archère Mira proposa son aide, tua le dragon d'un seul coup et épousa Arjun. Ils régnèrent ensemble, vivant heureux pour toujours, et Mira fut commémorée en tant que leur sauveuse.
Step 3 - Results so far:
johndoe1234@example.com
Step 4 - COMPLETE!
Sent email to: johndoe1234@example.com. Body: Dans un royaume lointain, le roi Arjun régnait de manière juste, mais un dragon terrorisait son peuple. L'archère Mira proposa son aide, tua le dragon d'un seul coup et épousa Arjun. Ils régnèrent ensemble, vivant heureux pour toujours, et Mira fut commémorée en tant que leur sauveuse.

======== Sequential Planner - Find and Execute Saved Plan ========
Goal: Write summary in french and e-mail John Doe
Searching for saved plan...
Restored plan (relevance=0.9370563865513345):
 Goal: Summarize an input, translate to french, and e-mail to John Doe

 Steps:
  - SummarizeSkill.Summarize INPUT='$INPUT' => SUMMARIZED_TEXT
  - WriterSkill.Translate INPUT='$SUMMARIZED_TEXT' language='French' => FRENCH_SUMMARY
  - email.GetEmailAddress INPUT='John Doe' => JOHN_DOE_EMAIL
  - email.SendEmail email_address='$JOHN_DOE_EMAIL' INPUT='$FRENCH_SUMMARY'

Result:
Sent email to: johndoe1234@example.com. Body: Dans un futur lointain, Remy, 15 ans, découvre un secret dangereux, ce qui le force à fuir avec l'aide d'Eve. Poursuivis par la Fédération Galactique, ils découvrent son passé, révélant qu'il n'est pas un garçon ordinaire.

Contribution Checklist

@shawncal shawncal added the .NET Issue or Pull requests regarding .NET code label Aug 8, 2023
@shawncal shawncal changed the title Update Sequential Planner example with plan recall .Net: Update Sequential Planner example with plan recall Aug 8, 2023
@lemillermicrosoft lemillermicrosoft marked this pull request as ready for review August 8, 2023 22:33
@lemillermicrosoft lemillermicrosoft requested a review from a team as a code owner August 8, 2023 22:33
This commit updates the Sequential Planner example to include a new
feature that demonstrates how to save and recall a plan for future use.
It also refactors some code to improve readability and maintainability,
such as extracting methods for initializing the kernel with memory and
retrieving the memory store.
📝 Update copyright notice in Example12_SequentialPlanner.cs

Update the copyright notice in the Example12_SequentialPlanner.cs file
to include the Unicode BOM. No other changes were made in this commit.
Rearrange and refactor the methods for initializing the kernel, memory,
and planner in Example12_SequentialPlanner.cs. This change improves the
code organization and makes it easier to understand the initialization
process.
@lemillermicrosoft lemillermicrosoft force-pushed the 808_plan_restore_sample branch from 7eed689 to 8249b94 Compare August 9, 2023 15:45
Removed unnecessary else block and simplified the memory
initialization process in the Example12_SequentialPlanner class. This
change makes the code more readable and easier to maintain.
@lemillermicrosoft lemillermicrosoft added the PR: ready for review All feedback addressed, ready for reviews label Aug 9, 2023
@lemillermicrosoft lemillermicrosoft added the PR: ready to merge PR has been approved by all reviewers, and is ready to merge. label Aug 15, 2023
Copy link
Member

@rogerbarreto rogerbarreto left a comment

Choose a reason for hiding this comment

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

LGTM

@lemillermicrosoft lemillermicrosoft added this pull request to the merge queue Aug 16, 2023
Merged via the queue into microsoft:main with commit d2c4f35 Aug 16, 2023
@lemillermicrosoft lemillermicrosoft deleted the 808_plan_restore_sample branch August 16, 2023 16:16
SOE-YoungS pushed a commit to SOE-YoungS/semantic-kernel that referenced this pull request Nov 1, 2023
)

This commit updates the Sequential Planner example to include a new
feature that demonstrates how to save and recall a plan for future use.
It also refactors some code to improve readability and maintainability,
such as extracting methods for initializing the kernel with memory and
retrieving the memory store.

Resolves microsoft#2343 

### Example Output
```
======== Sequential Planner - Create and Execute Email Plan ========
Original plan:
 Goal: Summarize an input, translate to french, and e-mail to John Doe

 Steps:
  - SummarizeSkill.Summarize INPUT='$INPUT' => SUMMARIZED_TEXT
  - WriterSkill.Translate input='$SUMMARIZED_TEXT' language='French' => FRENCH_SUMMARY
  - email.GetEmailAddress INPUT='John Doe' => JOHN_DOE_EMAIL
  - email.SendEmail email_address='$JOHN_DOE_EMAIL' INPUT='$FRENCH_SUMMARY'
Step 1 - Results so far:
In a distant kingdom, King Arjun ruled fairly, but a dragon terrorized his people. Archer Mira offered help, killed the dragon with one shot, and married Arjun. They ruled together, living happily ever after, with Mira remembered as their savior.
Step 2 - Results so far:
Dans un royaume lointain, le roi Arjun régnait de manière juste, mais un dragon terrorisait son peuple. L'archère Mira proposa son aide, tua le dragon d'un seul coup et épousa Arjun. Ils régnèrent ensemble, vivant heureux pour toujours, et Mira fut commémorée en tant que leur sauveuse.
Step 3 - Results so far:
johndoe1234@example.com
Step 4 - COMPLETE!
Sent email to: johndoe1234@example.com. Body: Dans un royaume lointain, le roi Arjun régnait de manière juste, mais un dragon terrorisait son peuple. L'archère Mira proposa son aide, tua le dragon d'un seul coup et épousa Arjun. Ils régnèrent ensemble, vivant heureux pour toujours, et Mira fut commémorée en tant que leur sauveuse.

======== Sequential Planner - Find and Execute Saved Plan ========
Goal: Write summary in french and e-mail John Doe
Searching for saved plan...
Restored plan (relevance=0.9370563865513345):
 Goal: Summarize an input, translate to french, and e-mail to John Doe

 Steps:
  - SummarizeSkill.Summarize INPUT='$INPUT' => SUMMARIZED_TEXT
  - WriterSkill.Translate INPUT='$SUMMARIZED_TEXT' language='French' => FRENCH_SUMMARY
  - email.GetEmailAddress INPUT='John Doe' => JOHN_DOE_EMAIL
  - email.SendEmail email_address='$JOHN_DOE_EMAIL' INPUT='$FRENCH_SUMMARY'

Result:
Sent email to: johndoe1234@example.com. Body: Dans un futur lointain, Remy, 15 ans, découvre un secret dangereux, ce qui le force à fuir avec l'aide d'Eve. Poursuivis par la Fédération Galactique, ils découvrent son passé, révélant qu'il n'est pas un garçon ordinaire.
```

### 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 😄

---------

Co-authored-by: Shawn Callegari <36091529+shawncal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Issue or Pull requests regarding .NET code PR: ready for review All feedback addressed, ready for reviews PR: ready to merge PR has been approved by all reviewers, and is ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Sample] Ability to save and recall plans

4 participants