mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix: merge plugin tools into builtin toolsets
This commit is contained in:
parent
d9f0875591
commit
0120d8f31e
2 changed files with 23 additions and 3 deletions
|
|
@ -32,6 +32,21 @@ class TestGetToolset:
|
||||||
assert ts is not None
|
assert ts is not None
|
||||||
assert "web_search" in ts["tools"]
|
assert "web_search" in ts["tools"]
|
||||||
|
|
||||||
|
def test_merges_registry_tools_into_builtin_toolset(self, monkeypatch):
|
||||||
|
reg = ToolRegistry()
|
||||||
|
reg.register(
|
||||||
|
name="web_search_plus",
|
||||||
|
toolset="web",
|
||||||
|
schema=_make_schema("web_search_plus", "Plugin web search"),
|
||||||
|
handler=_dummy_handler,
|
||||||
|
)
|
||||||
|
|
||||||
|
monkeypatch.setattr("tools.registry.registry", reg)
|
||||||
|
|
||||||
|
ts = get_toolset("web")
|
||||||
|
assert ts is not None
|
||||||
|
assert set(ts["tools"]) == {"web_search", "web_extract", "web_search_plus"}
|
||||||
|
|
||||||
def test_unknown_returns_none(self):
|
def test_unknown_returns_none(self):
|
||||||
assert get_toolset("nonexistent") is None
|
assert get_toolset("nonexistent") is None
|
||||||
|
|
||||||
|
|
|
||||||
11
toolsets.py
11
toolsets.py
|
|
@ -521,13 +521,18 @@ def get_toolset(name: str) -> Optional[Dict[str, Any]]:
|
||||||
None: If toolset not found
|
None: If toolset not found
|
||||||
"""
|
"""
|
||||||
toolset = TOOLSETS.get(name)
|
toolset = TOOLSETS.get(name)
|
||||||
if toolset:
|
|
||||||
return toolset
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from tools.registry import registry
|
from tools.registry import registry
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return toolset if toolset else None
|
||||||
|
|
||||||
|
if toolset:
|
||||||
|
merged_tools = sorted(
|
||||||
|
set(toolset.get("tools", []))
|
||||||
|
| set(registry.get_tool_names_for_toolset(name))
|
||||||
|
)
|
||||||
|
return {**toolset, "tools": merged_tools}
|
||||||
|
|
||||||
registry_toolset = name
|
registry_toolset = name
|
||||||
description = f"Plugin toolset: {name}"
|
description = f"Plugin toolset: {name}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue