Set tool annotations by decorating the tool function, not in `chat.register_tool()`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
调研方向
首先阅读 chat.register_tool() 的实现和现有的工具注解处理逻辑,然后查看 issue #169 中的相关问题。当可以通过装饰器在工具函数上声明注解,并且 register_tool() 可以在不单独提供注解的情况下使用经过装饰的函数时,此更改即告完成。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 179
- 派生
- 32
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 10
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
posit-dev/chatlas 的其他 Issue
-
A streaming text delta that repeats everything streamed so far is missing from the recorded turn可能已有人在做 @cpsievert 于 81 天前认领。 未关闭ai-triage:done Priority: Medium
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
ai-triage:needs-review documentation
难度 2/5 1-2 天 新手友好度 76/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
维护者通常 1 天内回复
-
难度 4/5 1-2 天 新手友好度 35/100
维护者通常 1 天内回复
-
ai-triage:done Priority: Low
难度 3/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
查看 posit-dev/chatlas 的全部 Issue
相似的 Issue
-
accepted
难度 2/5 1-3 小时 新手友好度 68/100
future-agi/future-agi#6392 ·
维护者通常 1 天内回复
-
memmapped_arange ignores the start value and drops the last point above the memmap threshold可能已有人在做 @prathameshfuke 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
StingraySoftware/HENDRICS#213 ·
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
Bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
bot-triaged module: decompositions module: edge cases module: int overflow module: primTorch oncall: pt2 triage review
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复