Refactor Stepwise Planner handler, added logic to allow use of stepwise plan result as bot response#514
Merged
teresaqhoang merged 3 commits intomicrosoft:mainfrom Oct 18, 2023
Conversation
…se plan result as bot response
alliscode
approved these changes
Oct 18, 2023
TaoChenOSU
approved these changes
Oct 18, 2023
teamleader-dev
pushed a commit
to vlink-group/chat-copilot
that referenced
this pull request
Oct 7, 2024
…se plan result as bot response (microsoft#514) ### Motivation and Context <!-- Thank you for your contribution to the chat-copilot 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 pull request refactors the use of Stepwise Planner in CC. The changes include a fix to embed the result of the Stepwise Planner into the meta prompt if a valid result is returned and adds a new property to PlannerOptions to indicate whether to use the planner result as the bot response. Additionally, the ChatSkill class has been updated to handle the new changes, including adding the ability to pass a response string to the HandleBotResponseAsync method and changing the StepwiseThoughtProcess property to a PlanExecutionMetadata object. The PromptDialog component has also been updated to display the Stepwise Planner supplement and raw view when appropriate, and the BotResponsePrompt interface has been updated to include a rawView property (to show the Stepwise Thought Process if the webapi is configured to return the stepwise response directly). ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Logic: 1. If Stepwise Planner doesn't return a valid result (i.e., "Result not found"), continue with regular response generation. Planner result will not be included in meta prompt.  2. If Stepwise Planner returns a valid result, that result will be supplemented with complementary text to guide the model in using this response in the meta prompt.  3. If Stepwise Planner returns a valid result and the webapi is configured to use this result directly, it will be immediately returned to the client.  Change Details: - Update ExternalInformation property in BotResponsePrompt to use SemanticDependency of PlanExecutionMetadata instead of ISemanticDependency. - Rename StepwiseThoughtProcess class to PlanExecutionMetadata. - Add RawResult property to PlanExecutionMetadata to store the raw result of the planner. - Add UseStepwiseResultAsBotResponse property to PlannerOptions to indicate whether to use the planner result as the bot response. - Add StepwisePlannerSupplement property to PromptsOptions to help guide model in using a response from StepwisePlanner. - Update ChatSkill to use SemanticDependency of PlanExecutionMetadata instead of StepwiseThoughtProcess. - Add logic to handle using plan result as bot response if UseStepwiseResultAsBotResponse is true. - Update HandleBotResponseAsync method to accept rawResult parameter. Stepwise Thought Proceses available in Prompt details anytime the Stepwise planner is used, even if no result is found.  ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [Contribution Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/chat-copilot/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 😄
kb0039
pushed a commit
to aaronba/chat-copilot
that referenced
this pull request
Jan 8, 2025
…se plan result as bot response (microsoft#514) ### Motivation and Context <!-- Thank you for your contribution to the chat-copilot 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 pull request refactors the use of Stepwise Planner in CC. The changes include a fix to embed the result of the Stepwise Planner into the meta prompt if a valid result is returned and adds a new property to PlannerOptions to indicate whether to use the planner result as the bot response. Additionally, the ChatSkill class has been updated to handle the new changes, including adding the ability to pass a response string to the HandleBotResponseAsync method and changing the StepwiseThoughtProcess property to a PlanExecutionMetadata object. The PromptDialog component has also been updated to display the Stepwise Planner supplement and raw view when appropriate, and the BotResponsePrompt interface has been updated to include a rawView property (to show the Stepwise Thought Process if the webapi is configured to return the stepwise response directly). ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Logic: 1. If Stepwise Planner doesn't return a valid result (i.e., "Result not found"), continue with regular response generation. Planner result will not be included in meta prompt.  2. If Stepwise Planner returns a valid result, that result will be supplemented with complementary text to guide the model in using this response in the meta prompt.  3. If Stepwise Planner returns a valid result and the webapi is configured to use this result directly, it will be immediately returned to the client.  Change Details: - Update ExternalInformation property in BotResponsePrompt to use SemanticDependency of PlanExecutionMetadata instead of ISemanticDependency. - Rename StepwiseThoughtProcess class to PlanExecutionMetadata. - Add RawResult property to PlanExecutionMetadata to store the raw result of the planner. - Add UseStepwiseResultAsBotResponse property to PlannerOptions to indicate whether to use the planner result as the bot response. - Add StepwisePlannerSupplement property to PromptsOptions to help guide model in using a response from StepwisePlanner. - Update ChatSkill to use SemanticDependency of PlanExecutionMetadata instead of StepwiseThoughtProcess. - Add logic to handle using plan result as bot response if UseStepwiseResultAsBotResponse is true. - Update HandleBotResponseAsync method to accept rawResult parameter. Stepwise Thought Proceses available in Prompt details anytime the Stepwise planner is used, even if no result is found.  ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [Contribution Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/chat-copilot/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 😄
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This pull request refactors the use of Stepwise Planner in CC. The changes include a fix to embed the result of the Stepwise Planner into the meta prompt if a valid result is returned and adds a new property to PlannerOptions to indicate whether to use the planner result as the bot response.
Additionally, the ChatSkill class has been updated to handle the new changes, including adding the ability to pass a response string to the HandleBotResponseAsync method and changing the StepwiseThoughtProcess property to a PlanExecutionMetadata object. The PromptDialog component has also been updated to display the Stepwise Planner supplement and raw view when appropriate, and the BotResponsePrompt interface has been updated to include a rawView property (to show the Stepwise Thought Process if the webapi is configured to return the stepwise response directly).
Description
Logic:
If Stepwise Planner doesn't return a valid result (i.e., "Result not found"), continue with regular response generation. Planner result will not be included in meta prompt.

If Stepwise Planner returns a valid result, that result will be supplemented with complementary text to guide the model in using this response in the meta prompt.

If Stepwise Planner returns a valid result and the webapi is configured to use this result directly, it will be immediately returned to the client.

Change Details:
Stepwise Thought Proceses available in Prompt details anytime the Stepwise planner is used, even if no result is found.

Contribution Checklist
- [ ] All unit tests pass, and I have added new tests where possible