Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Python: input_variables default values are never applied when rendering templates

未关闭
#14,458 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 5 天内回复

@ManoharPaturi 已经在做这个了。

开始于 2026年9月18日。

  • #14459 来自 @ManoharPaturi —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
ai

调研方向

先从 KernelPromptTemplate.render 和 VarBlock.render 开始,然后检查 PromptTemplateConfig.input_variables 和 get_kernel_parameter_metadata。分别用缺少名称和显式参数的情况重现该示例;当调用方省略变量时才显示声明的默认值,而显式值仍然优先时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

python triage
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

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/semantic-kernel 的其他 Issue

查看 microsoft/semantic-kernel 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。