Python: Bug: TimePlugin timeZoneOffset and timeZoneName always return an empty string
Maintainer thường phản hồi trong vòng 5 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 80/100
Hướng nghiên cứu
Lỗi nằm ở python/semantic_kernel/core_plugins/time_plugin.py, trong time_zone_offset và time_zone_name. Hai hàm này gọi datetime.datetime.now() không kèm múi giờ nên nhận về %z và %Z rỗng. Hãy đọc các unit test hiện có của TimePlugin, nơi test_mock_now patch now bằng một giá trị có múi giờ UTC, rồi tái hiện lỗi bằng đoạn mã trong issue. Hoàn thành khi cả hai hàm trả về độ lệch múi giờ và tên múi giờ cục bộ khi được gọi với đồng hồ không có múi giờ, và có một test bao phủ đường đi này mà không dùng mock có múi giờ UTC.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
TimePlugin.timeZoneOffset and TimePlugin.timeZoneName always return an empty string.
Where
python/semantic_kernel/core_plugins/time_plugin.py:
@kernel_function(description="Get the current time zone offset", name="timeZoneOffset")
def time_zone_offset(self) -> str:
"""... {{time.timeZoneOffset}} => -08:00"""
now = datetime.datetime.now()
return now.strftime("%z")
@kernel_function(description="Get the current time zone name", name="timeZoneName")
def time_zone_name(self) -> str:
"""... {{time.timeZoneName}} => PST"""
now = datetime.datetime.now()
return now.strftime("%Z")
datetime.datetime.now() without a tz argument returns a naive datetime. For a naive datetime strftime("%z") and strftime("%Z") return "".
The existing unit tests do not catch this because they patch datetime.datetime.now to return a timezone-aware UTC value (test_mock_now), which never happens in real use.
To reproduce
Checked on current main (1b1f64b98), Python 3.13, Windows, local zone US Eastern.
import datetime
from semantic_kernel.core_plugins.time_plugin import TimePlugin
t = TimePlugin()
print(repr(t.time_zone_offset()), repr(t.time_zone_name()))
now = datetime.datetime.now().astimezone()
print(repr(now.strftime("%z")), repr(now.strftime("%Z")))
Actual:
'' ''
'-0400' 'Eastern Daylight Time'
A prompt template such as Time zone: {{time.timeZoneName}} ({{time.timeZoneOffset}}) renders as Time zone: ().
Expected
Both functions return the local zone offset and name. Using datetime.datetime.now().astimezone() gives an aware datetime in the local zone, so %z and %Z are filled.
I have a fix with tests ready and will open a PR for this.
Platform
- Language: Python
- Source: main branch of the repository (1b1f64b98)
- Ngôn ngữ chính
- C#
- Star
- 28.7k
- Fork
- 4.8k
- Merge trung bình
- 6 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 53
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
-
.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 5 ngày
-
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)Có thể đã có người làm @VANDRANKI đã nhận 25 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 84/100
microsoft/semantic-kernel#14522 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Python: VolatileMemoryStore.get_nearest_match returns an un-awaited coroutine instead of a (MemoryRecord, score) tupleCó thể đã có người làm @VANDRANKI đã nhận 25 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 88/100
microsoft/semantic-kernel#14521 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
.Net: Bug: BinaryContent does not decode the %xx escapes of a non-base64 data URICó thể đã có người làm @Laurianti đã nhận 25 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 76/100
microsoft/semantic-kernel#14518 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Python: FunctionCallContent.combine_arguments drops a streamed "{}" chunk, producing invalid JSON argumentsCó thể đã có người làm @VANDRANKI đã nhận 26 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#14512 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày
Tất cả issue của microsoft/semantic-kernel
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
HicServices/RDMP#2398 ·
-
is:bug is:FQNIssue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
nunit/nunit3-vs-adapter#1527 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug effort:S P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
nightscout/nocturne#2840 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
fluentmigrator/fluentmigrator#2424 ·