Files
semantic-kernel/python/semantic_kernel/__init__.py
T
Eduard van Valkenburg 3af69df7ea Python: Handlebars template support (#5466)
### 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.
-->
Introducing Handlebars templating to the Python Semantic Kernel!

Closes: #5446
Prework for: #4641

### Description

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

<!-- 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 😄
2024-03-14 14:00:05 +00:00

47 lines
1.6 KiB
Python

# Copyright (c) Microsoft. All rights reserved.
from semantic_kernel import core_plugins, memory
from semantic_kernel.functions.kernel_arguments import KernelArguments
from semantic_kernel.functions.kernel_function import KernelFunction
from semantic_kernel.kernel import Kernel
from semantic_kernel.prompt_template.prompt_template_config import PromptTemplateConfig
from semantic_kernel.utils.logging import setup_logging
from semantic_kernel.utils.null_logger import NullLogger
from semantic_kernel.utils.settings import (
astradb_settings_from_dot_env,
azure_aisearch_settings_from_dot_env,
azure_aisearch_settings_from_dot_env_as_dict,
azure_cosmos_db_settings_from_dot_env,
azure_openai_settings_from_dot_env,
bing_search_settings_from_dot_env,
google_palm_settings_from_dot_env,
mongodb_atlas_settings_from_dot_env,
openai_settings_from_dot_env,
pinecone_settings_from_dot_env,
postgres_settings_from_dot_env,
redis_settings_from_dot_env,
)
__all__ = [
"Kernel",
"NullLogger",
"azure_cosmos_db_settings_from_dot_env",
"openai_settings_from_dot_env",
"azure_openai_settings_from_dot_env",
"azure_aisearch_settings_from_dot_env",
"azure_aisearch_settings_from_dot_env_as_dict",
"postgres_settings_from_dot_env",
"pinecone_settings_from_dot_env",
"astradb_settings_from_dot_env",
"bing_search_settings_from_dot_env",
"mongodb_atlas_settings_from_dot_env",
"google_palm_settings_from_dot_env",
"redis_settings_from_dot_env",
"PromptTemplateConfig",
"KernelArguments",
"KernelFunction",
"memory",
"core_plugins",
"setup_logging",
]