-
Notifications
You must be signed in to change notification settings - Fork 579
✨ Add Chinese localization for tool descriptions #2527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ca9ed62
feat: add Chinese localization for tool descriptions
0cb51f8
feat: add init_param_descriptions with i18n for exa_search_tool
c842f96
fix: add services module mock to fix test_add_tool_field test
762019b
fix: fix TypeScript type error in ToolTestPanel.tsx
8a7cf06
test: add tests for get_local_tools_description_zh function
774a32b
test: add tests for get_local_tools_description_zh i18n function
f9c1dbe
test: add tests for add_tool_field description_zh i18n merge logic
8601b99
test: fix test imports for get_local_tools_description_zh
958335c
Pre-download tiktoken cl100k_base model
WMC001 6c3e4d2
🐛 Bugfix: The agent_run process cannot invoke the MCP service with au…
WMC001 fa516a7
Merge remote-tracking branch 'origin/release/v1.8.0.1' into gerui-bugfix
9992be2
Merge remote-tracking branch 'origin/develop' into gerui-bugfix
ec3aa12
fix: 解决循环导入问题并清理工具参数描述
8447f08
fix: remove duplicate period in get_email_tool description_zh
a240575
fix: restore MCP transport functions and authorization support
b37c5a3
test: fix mock paths for get_local_tools_classes and get_local_tools_…
f8e8d4e
fix: restore MCP tool unique key logic and fix test mock paths
54eba07
fix: add missing ToolSourceEnum import and restore create_or_update_t…
41efd51
test: add tests for description_zh coverage
2d234aa
test: fix mock paths and async tests for description_zh coverage
fe803fb
fix: add init_param_descriptions fallback for param description_zh
3eddd99
update docs and bugfix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import importlib | ||
| import inspect | ||
| from typing import List, Dict | ||
|
|
||
|
|
||
| def get_local_tools_classes() -> List[type]: | ||
| """ | ||
| Get all tool classes from the nexent.core.tools package | ||
|
|
||
| Returns: | ||
| List of tool class objects | ||
| """ | ||
| tools_package = importlib.import_module('nexent.core.tools') | ||
| tools_classes = [] | ||
| for name in dir(tools_package): | ||
| obj = getattr(tools_package, name) | ||
| if inspect.isclass(obj): | ||
| tools_classes.append(obj) | ||
| return tools_classes | ||
|
|
||
|
|
||
| def get_local_tools_description_zh() -> Dict[str, Dict]: | ||
|
Check failure on line 22 in backend/utils/tool_utils.py
|
||
|
WMC001 marked this conversation as resolved.
|
||
| """ | ||
| Get description_zh for all local tools from SDK (not persisted to DB). | ||
|
|
||
| Returns: | ||
| Dict mapping tool name to {"description_zh": ..., "params": [...], "inputs": {...}} | ||
| """ | ||
| tools_classes = get_local_tools_classes() | ||
| result = {} | ||
| for tool_class in tools_classes: | ||
| tool_name = getattr(tool_class, 'name') | ||
|
|
||
| description_zh = getattr(tool_class, 'description_zh', None) | ||
|
|
||
| init_param_descriptions = getattr(tool_class, 'init_param_descriptions', {}) | ||
|
|
||
| init_params_list = [] | ||
| sig = inspect.signature(tool_class.__init__) | ||
| for param_name, param in sig.parameters.items(): | ||
| if param_name == "self": | ||
| continue | ||
|
|
||
| # Check if parameter has a default value and if it should be excluded | ||
| if param.default != inspect.Parameter.empty: | ||
| if hasattr(param.default, 'exclude') and param.default.exclude: | ||
| continue | ||
|
|
||
| param_description_zh = param.default.description_zh if hasattr(param.default, 'description_zh') else None | ||
|
|
||
| if param_description_zh is None and param_name in init_param_descriptions: | ||
| param_description_zh = init_param_descriptions[param_name].get('description_zh') | ||
|
|
||
| init_params_list.append({ | ||
| "name": param_name, | ||
| "description_zh": param_description_zh | ||
| }) | ||
|
|
||
| tool_inputs = getattr(tool_class, 'inputs', {}) | ||
| inputs_description_zh = {} | ||
| if isinstance(tool_inputs, dict): | ||
| for key, value in tool_inputs.items(): | ||
| if isinstance(value, dict) and value.get("description_zh"): | ||
| inputs_description_zh[key] = { | ||
| "description_zh": value.get("description_zh") | ||
| } | ||
|
|
||
| result[tool_name] = { | ||
| "description_zh": description_zh, | ||
| "params": init_params_list, | ||
| "inputs": inputs_description_zh | ||
| } | ||
| return result | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.