mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2026-04-25 11:18:06 +00:00
add tool list routes
This commit is contained in:
parent
7494bad618
commit
d48e82f17e
2
Makefile
2
Makefile
@ -43,4 +43,4 @@ validate-yamls: ## Validate all YAML configuration files
|
||||
help: ## Display this help message
|
||||
@python -c "import re; \
|
||||
p=r'$(firstword $(MAKEFILE_LIST))'.strip(); \
|
||||
[print(f'{m[0]:<20} {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(p, encoding='utf-8').read(), re.M)]" | sort
|
||||
[print(f'{m[0]:<20} {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(p, encoding='utf-8').read(), re.M)]" | sort
|
||||
@ -1,6 +1,6 @@
|
||||
"""Aggregates API routers."""
|
||||
|
||||
from . import artifacts, execute, execute_sync, health, sessions, uploads, vuegraphs, workflows, websocket, batch
|
||||
from . import artifacts, execute, execute_sync, health, sessions, uploads, vuegraphs, workflows, websocket, batch, tools
|
||||
|
||||
ALL_ROUTERS = [
|
||||
health.router,
|
||||
@ -12,7 +12,8 @@ ALL_ROUTERS = [
|
||||
batch.router,
|
||||
execute.router,
|
||||
execute_sync.router,
|
||||
tools.router,
|
||||
websocket.router,
|
||||
]
|
||||
|
||||
__all__ = ["ALL_ROUTERS"]
|
||||
__all__ = ["ALL_ROUTERS"]
|
||||
|
||||
29
server/routes/tools.py
Normal file
29
server/routes/tools.py
Normal file
@ -0,0 +1,29 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from utils.function_catalog import get_function_catalog
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/api/tools/local")
|
||||
def list_local_tools():
|
||||
catalog = get_function_catalog()
|
||||
metadata = catalog.list_metadata()
|
||||
tools = []
|
||||
for name, meta in metadata.items():
|
||||
tools.append(
|
||||
{
|
||||
"name": name,
|
||||
"description": meta.description,
|
||||
"parameters": meta.parameters_schema,
|
||||
"module": meta.module_name,
|
||||
"file_path": meta.file_path,
|
||||
}
|
||||
)
|
||||
tools.sort(key=lambda item: item["name"])
|
||||
return {
|
||||
"success": True,
|
||||
"count": len(tools),
|
||||
"tools": tools,
|
||||
"load_error": str(catalog.load_error) if catalog.load_error else None,
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user