Files
semantic-kernel/python/semantic_kernel/template_engine/protocols/code_renderer.py
T
Jordan Henkel 016cd3334f Python: Upgrade PromptTemplateEngine (bring back to parity w/ C# version) (#200)
### Motivation and Context

The C# Semantic Kernel has recently undergone an upgrade to its
`PromptTemplateEngine`. This brings Python back in line with the
semantics of Prompt Templates in C#.

### Description

Here, unlike the original port, I've tried to make things more
pythonic/idiomatic (instead of trying to directly mirror the C#
codebase). I've also brought over the corresponding unit tests (and
added some of my own as I was building/validating).
2023-04-13 16:12:36 -07:00

22 lines
532 B
Python

# Copyright (c) Microsoft. All rights reserved.
from typing import Protocol, runtime_checkable
from semantic_kernel.orchestration.sk_context import SKContext
@runtime_checkable
class CodeRenderer(Protocol):
"""
Protocol for dynamic code blocks that need async IO to be rendered.
"""
async def render_code_async(self, context: SKContext) -> str:
"""
Render the block using the given context.
:param context: SK execution context
:return: Rendered content
"""
...