Python: input_variables default values are never applied when rendering templates
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu với KernelPromptTemplate.render và VarBlock.render, sau đó kiểm tra PromptTemplateConfig.input_variables và get_kernel_parameter_metadata. Tái hiện ví dụ với tên bị thiếu và với một đối số tường minh; hoàn tất khi giá trị mặc định đã khai báo chỉ xuất hiện khi bên gọi bỏ qua biến, còn giá trị tường minh vẫn được ưu tiên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- C#
- Star
- 28.7k
- Fork
- 4.8k
- Merge trung bình
- 1 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 28
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/semantic-kernel
-
Python: Rejected system messages leave AgentChat permanently activeCó thể đã có người làm @Michael-Duck đã nhận 3 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/semantic-kernel#14638 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Python: Bug: Anthropic, Bedrock, Google AI and Vertex AI tool formatters ignore include_in_function_choices=FalseCó thể đã có người làm @wasim-builds đã nhận 8 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
microsoft/semantic-kernel#14615 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Python: Bug: AnnotationContent and StreamingAnnotationContent to_element writes CitationType.X, so annotations in a rendered chat history fail to parseCó thể đã có người làm @CRYPTONIKAV đã nhận 12 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/semantic-kernel#14590 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Python: Bug: TimePlugin timeZoneOffset and timeZoneName always return an empty stringCó thể đã có người làm @jeevan1098 đã nhận 10 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
microsoft/semantic-kernel#14583 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23Có thể đã có người làm @nightcityblade đã nhận 23 ngày trước. Đang mở.NET triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
microsoft/semantic-kernel#14526 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/semantic-kernel
Issue tương tự
-
area:jobads-cv BE P3
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 74/100
klasolsson81/jobbliggaren#2240 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
k2-fsa/sherpa-onnx#4100 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
:watch: Not Triaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
unoplatform/uno.check#591 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
weaviate/csharp-client#378 ·