Python: input_variables default values are never applied when rendering templates
维护者通常 5 天内回复
评估
调研方向
先从 KernelPromptTemplate.render 和 VarBlock.render 开始,然后检查 PromptTemplateConfig.input_variables 和 get_kernel_parameter_metadata。分别用缺少名称和显式参数的情况重现该示例;当调用方省略变量时才显示声明的默认值,而显式值仍然优先时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Description
PromptTemplateConfig.input_variables supports a default per variable, it is even validated (must be a string) and exposed through get_kernel_parameter_metadata as default_value. But the value is never used when rendering: KernelPromptTemplate.render goes straight to the blocks, and VarBlock.render only reads KernelArguments, returning an empty string for anything missing.
Reproduction
from semantic_kernel import Kernel
from semantic_kernel.prompt_template.kernel_prompt_template import KernelPromptTemplate
from semantic_kernel.prompt_template.prompt_template_config import PromptTemplateConfig
import asyncio
cfg = PromptTemplateConfig(
name="t",
template="Hello {{$name}}!",
template_format="semantic-kernel",
input_variables=[{"name": "name", "description": "who", "default": "STRANGER"}],
)
tpl = KernelPromptTemplate(prompt_template_config=cfg)
print(repr(asyncio.run(tpl.render(Kernel())))) # 'Hello !' -- expected 'Hello STRANGER!'
Expected behavior
A declared default fills in when the caller did not supply the variable; an explicit argument still wins.
Environment
semantic-kernel python 1.44.1, pydantic v2
- 主要语言
- C#
- 星标
- 28.7k
- 派生
- 4.8k
- 平均合并
- 6 天 5 小时
- 30 天内合并 PR
- 53
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/semantic-kernel 的其他 Issue
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23可能已有人在做 @nightcityblade 于 23 天前认领。 未关闭.NET triage
难度 2/5 1-3 小时 新手友好度 73/100
microsoft/semantic-kernel#14526 · 1 条评论 ·
维护者通常 5 天内回复
-
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)可能已有人在做 @VANDRANKI 于 25 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 84/100
microsoft/semantic-kernel#14522 ·
维护者通常 5 天内回复
-
Python: VolatileMemoryStore.get_nearest_match returns an un-awaited coroutine instead of a (MemoryRecord, score) tuple可能已有人在做 @VANDRANKI 于 25 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 88/100
microsoft/semantic-kernel#14521 ·
维护者通常 5 天内回复
-
.Net: Bug: BinaryContent does not decode the %xx escapes of a non-base64 data URI可能已有人在做 @Laurianti 于 25 天前认领。 未关闭.NET triage
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/semantic-kernel#14518 ·
维护者通常 5 天内回复
-
Python: FunctionCallContent.combine_arguments drops a streamed "{}" chunk, producing invalid JSON arguments可能已有人在做 @VANDRANKI 于 26 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/semantic-kernel#14512 · 2 条评论 ·
维护者通常 5 天内回复
查看 microsoft/semantic-kernel 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
HicServices/RDMP#2398 ·
-
is:bug is:FQNIssue
难度 2/5 1-3 小时 新手友好度 72/100
nunit/nunit3-vs-adapter#1527 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
bug effort:S P3
难度 2/5 1-3 小时 新手友好度 72/100
nightscout/nocturne#2840 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
fluentmigrator/fluentmigrator#2424 ·