Set tool annotations by decorating the tool function, not in `chat.register_tool()`
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Bắt đầu bằng cách đọc phần triển khai của chat.register_tool() và cách xử lý chú thích công cụ hiện có, sau đó xem xét các vấn đề liên quan trong issue #169. Thay đổi được hoàn tất khi có thể khai báo chú thích trên hàm công cụ bằng decorator và register_tool() có thể sử dụng hàm đã được decorator mà không cần cung cấp chú thích riêng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Tool annotations should be attached to the tool definition as closely as possible. It's currently awkward to create to a tool function that has annotations because those annotations need to be passed to chat.register_tool() at registration, which might be in a different place than where the tool is defined. (The tool could be in packaged code and the registration in user code.)
Instead of this
import faicons
from chatlas import ChatOpenAI
def get_weather_forecast(
lat: float, lon: float, location_name: str
) -> ContentToolResult:
"""Get the weather forecast for a location."""
# Mocked weather data for demonstration purposes
return {"temperature_2m": 18, "condition": "Partly Cloudy"}
# Create chat client and register tool
chat_client = ChatOpenAI(model="gpt-4.1-nano")
chat_client.register_tool(
get_weather_forecast,
annotations={ # << THIS COULD HAPPEN FAR FROM TOOL DEL
"title": "Weather Forecast",
"icon": faicons.icon_svg("cloud"),
},
)
Maybe this
import faicons
from chatlas import ChatOpenAI, add_tool_annotations
@add_tool_annotations(
title="Weather Forecast",
icon=faicons.icon_svg("cloud")
)
def get_weather_forecast(
lat: float, lon: float, location_name: str
) -> ContentToolResult:
"""Get the weather forecast for a location."""
# Mocked weather data for demonstration purposes
return {"temperature_2m": 18, "condition": "Partly Cloudy"}
# Create chat client and register tool
chat_client = ChatOpenAI(model="gpt-4.1-nano")
chat_client.register_tool(get_weather_forecast)
Advantages
This would also resolve some of the underlying issue in #169 where known standard MCP Tool Annotation properties could be named arguments that are documented, but additional kwargs are just added as tool annotations.
- Ngôn ngữ chính
- Python
- Star
- 179
- Fork
- 32
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 10
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 posit-dev/chatlas
-
A streaming text delta that repeats everything streamed so far is missing from the recorded turnCó thể đã có người làm @cpsievert đã nhận 81 ngày trước. Đang mởai-triage:done Priority: Medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-triage:needs-review documentation
Độ khó 2/5 1-2 ngày Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-triage:done Priority: Low
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của posit-dev/chatlas
Issue tương tự
-
bot-triaged module: decompositions module: edge cases module: int overflow module: primTorch oncall: pt2 triage review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[TV SHOW]: Dynasty (1981)Đang mởcountry:US rating:6 request-theme type:TV SHOW
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
LizardByte/ThemerrDB#10501 · 1 bình luận ·
-
triage/confirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
agentscope-ai/agentscope#4563 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
comp/desktop desktop/chat P3 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
NousResearch/hermes-agent#164451 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
external integration integration-submission
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
langchain-ai/docs#8426 ·
Maintainer thường phản hồi trong vòng 1 ngày