Skip to content

✨ Add Chinese localization for tool descriptions#2527

Open
geruihappy-creator wants to merge 22 commits intodevelopfrom
gerui-bugfix
Open

✨ Add Chinese localization for tool descriptions#2527
geruihappy-creator wants to merge 22 commits intodevelopfrom
gerui-bugfix

Conversation

@geruihappy-creator
Copy link
Collaborator

本地工具描述的国际化,在智能体开发、智能体空间和市场页作适配
image
image
image

@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

❌ Patch coverage is 85.90604% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/services/tool_configuration_service.py 77.27% 1 Missing and 9 partials ⚠️
backend/utils/tool_utils.py 84.21% 1 Missing and 5 partials ⚠️
backend/database/tool_db.py 83.33% 0 Missing and 5 partials ⚠️

📢 Thoughts on this report? Let us know!



def add_tool_field(tool_info):
from services.tool_configuration_service import get_local_tools_description_zh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import 建议放到文件最前方,集中管理。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修正,谢谢。通过新建模块,确认该函数处不会循环导入,将from import前置到开头管理

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修正,谢谢。通过新建模块,确认该函数处不会循环导入,将from import前置到开头管理

WMC001 and others added 6 commits February 28, 2026 10:47
Pre-download tiktoken cl100k_base model
…thentication.

🐛 Bugfix: The agent_run process cannot invoke the MCP service with authentication.
1. 抽取 get_local_tools_description_zh 到独立模块 tool_local_service.py,避免循环导入
2. ToolInfo 模型添加 params: List 字段
3. 移除用户不感知参数(exclude=True)的 description_zh
4. 修复 send_email_tool description 中的 typo
葛锐 added 7 commits March 11, 2026 10:41
- Restore SSETransport and StreamableHttpTransport imports
- Restore get_mcp_authorization_token_by_name_and_url import
- Restore _create_mcp_transport function
- Update get_tool_from_remote_mcp_server to support tenant_id and authorization_token
- Update _call_mcp_tool to support authorization_token
- Update _validate_mcp_tool_remote to get authorization token from database
- Update get_all_mcp_tools to pass tenant_id
…description_zh

- Update mock paths from tool_configuration_service to tool_local_service
- Fix mock tool classes to use Field() for default values
- Update test_tool_db.py mock module setup
- Restore MCP tools unique key logic (name&source&usage) in update_tool_table_from_scan_tool_list
- Add user_id to MockToolInstanceClass in test
- Fix mock path for get_local_tools_description_zh in test_tool_db.py
…ool_by_tool_info logic

- Add ToolSourceEnum import to tool_db.py
- Restore create_or_update_tool_by_tool_info to not filter by user_id
- Restore proper ToolInstance creation logic
- Add tests for get_local_tools with description_zh extraction
- Add tests for list_all_tools merging description_zh from SDK
- Add tests for add_tool_field merging params and inputs description_zh
- Add tests for get_local_tools_classes direct call
- Add edge case tests for JSON decode errors and missing attributes
- Fix mock path from tool_local_service to tool_configuration_service for get_local_tools_classes
- Fix mock path for get_local_tools_description_zh
- Add @pytest.mark.asyncio for async list_all_tools tests
- Mock importlib.import_module for get_local_tools_classes direct test
Pydantic V2 doesn't support Field(description_zh=...) directly.
The actual tool classes use init_param_descriptions class attribute
for parameter description_zh. Updated get_local_tools() to check
init_param_descriptions as fallback when param.default.description_zh
is not available.
from database.client import get_db_session, filter_property, as_dict
from database.db_models import ToolInstance, ToolInfo
from consts.model import ToolSourceEnum
from services.tool_local_service import get_local_tools_description_zh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不应该出现db层调用service层的实现

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修正

return tools_classes


def get_local_tools_description_zh() -> Dict[str, Dict]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件中的函数建议放入utils中

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修正

init_params_list = []
sig = inspect.signature(tool_class.__init__)
for param_name, param in sig.parameters.items():
if param_name == "self" or param.default.exclude:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段代码直接访问了 param.default.exclude,而没有检查 param.default 是否存在或是否具有 exclude 属性。如果工具类中存在任何没有 Pydantic 字段默认值的参数,则 param.default 将为 inspect.Parameter.empty,缺少 exclude 属性,从而导致工具自省期间发生 AttributeError 崩溃。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修正

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants