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

Python: Remove jinja2 built in helpers from custom helpers. Introduce messages custom func helper. #5617

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

moonbox3
Copy link
Contributor

Motivation and Context

Jinja2 has a lot of built-in global functions, filters, and test methods. There's no need to have the overlap between those built-ins and the custom helpers we had defined.

Description

This PR:

  • Removes the overlap custom methods we had added so that one can use the built-in jinja2 filters, tests, and others.
  • Add some unit tests to exercise those built-ins, mainly to show how they can be used.
  • Introduces a messages custom helper function for handlebars and jinja2 which pretty prints the current chat_history.

Contribution Checklist

@moonbox3 moonbox3 requested a review from a team as a code owner March 22, 2024 23:04
@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label Mar 22, 2024
@github-actions github-actions bot changed the title Remove jinja2 built in helpers from custom helpers. Introduce messages custom func helper. Python: Remove jinja2 built in helpers from custom helpers. Introduce messages custom func helper. Mar 22, 2024
@markwallace-microsoft
Copy link
Member

Py3.8 Test Coverage

Python 3.8 Test Coverage Report •
FileStmtsMissCoverMissing
semantic_kernel/prompt_template/utils
   jinja2_system_helpers.py81298%37, 42
TOTAL540799482% 

Python 3.8 Unit Test Overview

Tests Skipped Failures Errors Time
1217 11 💤 0 ❌ 0 🔥 26.835s ⏱️

@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Mar 25, 2024
Merged via the queue into microsoft:main with commit 79620c7 Mar 25, 2024
31 checks passed
LudoCorporateShark pushed a commit to LudoCorporateShark/semantic-kernel that referenced this pull request Aug 25, 2024
… messages custom func helper. (microsoft#5617)

### Motivation and Context

Jinja2 has a lot of built-in global functions, filters, and test
methods. There's no need to have the overlap between those built-ins and
the custom helpers we had defined.

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

### Description

This PR:
- Removes the overlap custom methods we had added so that one can use
the built-in jinja2 filters, tests, and others.
- Add some unit tests to exercise those built-ins, mainly to show how
they can be used.
- Introduces a `messages` custom helper function for handlebars and
jinja2 which pretty prints the current chat_history.

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

### 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 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants