mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 11:19:56 +00:00
### 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).
22 lines
532 B
Python
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
|
|
"""
|
|
...
|