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: Bug fixes for Handlebars Prompt Template and Planner #4528

Conversation

markwallace-microsoft
Copy link
Member

Motivation and Context

Squashing bugs related to variable access in the Handlebars Prompt Template Factory and enhancing the Handlebars Planner Create Plan prompt.

Since we allow the planner to set variables after initial render call, these variables that are added during plan execution are not bound to the template and will resolve as an UndefinedBindingResult as the template evaluates. This PR adds a fix to handle that scenario.

Description

Resolving variables:

  • If the argument is of type UndefinedBindingResult, it means that Handlebars attempted to retrieve the value for a binding but was unable to do so because the variable was not defined or not passed to the template context at the time of render. Thus, we try to get the value from the kernel arguments dictionary.

Contribution Checklist

Sorry, something went wrong.

teresaqhoang and others added 8 commits December 21, 2023 16:07

Verified

This commit was signed with the committer’s verified signature.
djhi Gildas Garcia

Verified

This commit was signed with the committer’s verified signature.
djhi Gildas Garcia

Verified

This commit was signed with the committer’s verified signature.
djhi Gildas Garcia

Verified

This commit was signed with the committer’s verified signature.
djhi Gildas Garcia

Verified

This commit was signed with the committer’s verified signature.
djhi Gildas Garcia

Verified

This commit was signed with the committer’s verified signature.
djhi Gildas Garcia

Verified

This commit was signed with the committer’s verified signature.
djhi Gildas Garcia

Verified

This commit was signed with the committer’s verified signature.
djhi Gildas Garcia
@markwallace-microsoft markwallace-microsoft requested a review from a team as a code owner January 9, 2024 09:37
@markwallace-microsoft markwallace-microsoft self-assigned this Jan 9, 2024
@shawncal shawncal added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Jan 9, 2024
@markwallace-microsoft markwallace-microsoft added this pull request to the merge queue Jan 11, 2024
Merged via the queue into microsoft:main with commit b7defcf Jan 11, 2024
@markwallace-microsoft markwallace-microsoft deleted the users/markwallace/hb-bug-squashing branch January 11, 2024 10:30
Bryan-Roe pushed a commit to Bryan-Roe-ai/semantic-kernel that referenced this pull request Oct 6, 2024

Verified

This commit was signed with the committer’s verified signature.
djhi Gildas Garcia
…#4528)

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

Squashing bugs related to variable access in the Handlebars Prompt
Template Factory and enhancing the Handlebars Planner Create Plan
prompt.

Since we allow the planner to set variables after initial render call,
these variables that are added during plan execution are not bound to
the template and will resolve as an `UndefinedBindingResult` as the
template evaluates. This PR adds a fix to handle that scenario.

### Description

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

Resolving variables:
- If the argument is of type `UndefinedBindingResult`, it means that
Handlebars attempted to retrieve the value for a binding but was unable
to do so because the variable was not defined or not passed to the
template context at the time of render. Thus, we try to get the value
from the kernel arguments dictionary.

### 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: Teresa Hoang <tehoang@microsoft.com>
Co-authored-by: Teresa Hoang <125500434+teresaqhoang@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants