forked from Rockachopa/Timmy-time-dashboard
Memory Unification + Canonical Identity: -11,074 lines of homebrew (#119)
This commit is contained in:
committed by
GitHub
parent
785440ac31
commit
62ef1120a4
@@ -6,10 +6,9 @@ Shows available tools and usage statistics.
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import APIRouter, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.responses import HTMLResponse, JSONResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from brain.client import BrainClient
|
||||
from timmy.tools import get_all_available_tools
|
||||
|
||||
router = APIRouter(tags=["tools"])
|
||||
@@ -20,26 +19,30 @@ templates = Jinja2Templates(directory=str(Path(__file__).parent.parent / "templa
|
||||
async def tools_page(request: Request):
|
||||
"""Render the tools dashboard page."""
|
||||
available_tools = get_all_available_tools()
|
||||
brain = BrainClient()
|
||||
|
||||
# Get recent tool usage from brain memory
|
||||
recent_memories = await brain.get_recent(hours=24, limit=50, sources=["timmy"])
|
||||
|
||||
# Simple tool list - no persona filtering
|
||||
tool_list = []
|
||||
for tool_id, tool_info in available_tools.items():
|
||||
tool_list.append({
|
||||
"id": tool_id,
|
||||
"name": tool_info.get("name", tool_id),
|
||||
"description": tool_info.get("description", ""),
|
||||
"available": True,
|
||||
})
|
||||
|
||||
|
||||
# Build agent tools list from the available tools
|
||||
agent_tools = []
|
||||
|
||||
# Calculate total calls (placeholder — would come from brain memory)
|
||||
total_calls = 0
|
||||
|
||||
return templates.TemplateResponse(
|
||||
"tools.html",
|
||||
{
|
||||
"request": request,
|
||||
"tools": tool_list,
|
||||
"recent_activity": len(recent_memories),
|
||||
}
|
||||
"available_tools": available_tools,
|
||||
"agent_tools": agent_tools,
|
||||
"total_calls": total_calls,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@router.get("/tools/api/stats", response_class=JSONResponse)
|
||||
async def tools_api_stats():
|
||||
"""Return tool statistics as JSON."""
|
||||
available_tools = get_all_available_tools()
|
||||
|
||||
return {
|
||||
"all_stats": {},
|
||||
"available_tools": list(available_tools.keys()),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user