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: Handlebars template support #5466

Merged
merged 12 commits into from
Mar 14, 2024

Conversation

eavanvalkenburg
Copy link
Member

@eavanvalkenburg eavanvalkenburg commented Mar 13, 2024

Motivation and Context

Introducing Handlebars templating to the Python Semantic Kernel!

Closes: #5446
Prework for: #4641

Description

Adds HandlebarsPromptTemplate as a subclass of PromptTemplateBase
Adds second literal to the PromptTemplateConfig definition
Adds helpers for Handlebars (system_helpers) and create_helper_from_function function
Moves fully_qualified_name into KernelFunctionMetadata instead of in different extensions.
Defaults are still 'semantic-kernel' templates, and without making explicit changes that still is the norm.
Adds a azure_chat_gpt_handlebars.py sample

Contribution Checklist

@eavanvalkenburg eavanvalkenburg requested a review from a team as a code owner March 13, 2024 21:19
@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label Mar 13, 2024
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Mar 13, 2024

Py3.8 Test Coverage

Python 3.8 Test Coverage Report •
FileStmtsMissCoverMissing
semantic_kernel
   kernel.py3233091%190–194, 196–200, 202–206, 214–216, 235, 241, 243–247, 249–253, 255–260, 262, 307–311, 328–333, 340, 344–348, 361, 472, 616
semantic_kernel/connectors/ai/open_ai
   utils.py473623%27–28, 51–55, 62–63, 104, 137–165
semantic_kernel/functions
   kernel_function.py57296%119, 138
   kernel_function_from_prompt.py125398%164, 192, 291
semantic_kernel/planners
   planner_extensions.py361656%20–29, 33, 37–38, 51–58, 66–77
semantic_kernel/planners/sequential_planner
   sequential_planner.py65592%71, 75, 106, 122, 130
   sequential_planner_extensions.py55984%35–36, 57, 108–126
   sequential_planner_parser.py771284%63–72, 92, 115–118
semantic_kernel/planners/stepwise_planner
   stepwise_planner.py22514137%12, 95, 109–127, 136–206, 227–230, 238–249, 252, 260–275, 278–314, 317–345, 348–353, 356–368, 371–374, 387–399, 402
semantic_kernel/prompt_template
   kernel_prompt_template.py80396%112–114
   prompt_template_config.py51590%47, 68, 73–74, 82
TOTAL5064100480% 

Python 3.8 Unit Test Overview

Tests Skipped Failures Errors Time
1060 11 💤 0 ❌ 0 🔥 21.217s ⏱️

@eavanvalkenburg eavanvalkenburg force-pushed the handlebars_template branch 2 times, most recently from 6db20af to 44fb45c Compare March 13, 2024 21:43
Copy link
Contributor

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

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

Looking great

Copy link
Contributor

@juliomenendez juliomenendez left a comment

Choose a reason for hiding this comment

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

Looks good, besides @moonbox3 comments I didn't see anything else to change.

Copy link
Contributor

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

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

Awesome work.

@moonbox3 moonbox3 enabled auto-merge March 14, 2024 13:00
@moonbox3 moonbox3 added this pull request to the merge queue Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 14, 2024
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 14, 2024
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Mar 14, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 14, 2024
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Mar 14, 2024
@eavanvalkenburg eavanvalkenburg removed this pull request from the merge queue due to a manual request Mar 14, 2024
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Mar 14, 2024
Merged via the queue into microsoft:main with commit 3af69df Mar 14, 2024
30 checks passed
@eavanvalkenburg eavanvalkenburg deleted the handlebars_template branch March 14, 2024 14:08
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.

Python: Implement handlebars templates
4 participants