Spaces:
Running
Running
| """ | |
| backend/api/bootstrap_tools.py — Inizializza e registra i tool predefiniti all'avvio. | |
| """ | |
| import logging | |
| from .tool_engine import tool_registry, ToolDescriptor | |
| _logger = logging.getLogger("api.bootstrap_tools") | |
| async def bootstrap_all_tools(): | |
| """ | |
| Registra i tool fondamentali nel ToolEngine. | |
| Questi tool diventano capability disponibili per il Brain. | |
| """ | |
| tools = [ | |
| ToolDescriptor( | |
| name="web_search", | |
| description="Cerca informazioni sul web in tempo reale", | |
| provider_id="hf-space-1", | |
| input_schema={"type": "object", "properties": {"query": {"type": "string"}}}, | |
| tags=["search", "web"] | |
| ), | |
| ToolDescriptor( | |
| name="python_interpreter", | |
| description="Esegue codice Python in una sandbox sicura", | |
| provider_id="oracle-cloud-vm-01", | |
| input_schema={"type": "object", "properties": {"code": {"type": "string"}}}, | |
| tags=["code", "sandbox"] | |
| ), | |
| ToolDescriptor( | |
| name="vision_analysis", | |
| description="Analizza immagini e screenshot tramite OCR e modelli Vision", | |
| provider_id="hf-space-2", | |
| input_schema={"type": "object", "properties": {"image_url": {"type": "string"}}}, | |
| tags=["vision", "ocr"] | |
| ) | |
| ] | |
| for tool in tools: | |
| try: | |
| await tool_registry.register(tool, force=True) | |
| except Exception as e: | |
| _logger.error(f"Errore registrazione tool {tool.name}: {e}") | |
| _logger.info(f"Bootstrap completato: {len(tools)} tool registrati.") | |