# LLM Routing Layer Routes LLM requests to the appropriate agent (work or family) based on identity, origin, or explicit specification. ## Features - **Automatic Routing**: Routes based on client type, origin, or explicit agent type - **Health Checks**: Verify LLM server availability - **Request Handling**: Make requests to routed servers - **Fallback**: Defaults to family agent for safety ## Usage ```python from routing.router import get_router router = get_router() # Route a request routing = router.route_request( agent_type="family", # Explicit # or client_type="phone", # Based on client # or origin="10.0.1.100" # Based on origin ) # Make request response = router.make_request( routing=routing, messages=[ {"role": "user", "content": "What time is it?"} ], tools=[...] # Optional tool definitions ) # Health check is_healthy = router.health_check("work") ``` ## Routing Logic 1. **Explicit Agent Type**: If `agent_type` is specified, use it 2. **Client Type**: Route based on client type (work/desktop → work, phone/tablet → family) 3. **Origin/IP**: Route based on network origin (if configured) 4. **Default**: Family agent (safer default) ## Configuration ### Work Agent (4080) - **URL**: http://10.0.30.63:11434 - **Model**: llama3.1:8b (configurable) - **Timeout**: 300 seconds ### Family Agent (1050) - **URL**: http://localhost:11434 (placeholder) - **Model**: phi3:mini-q4_0 - **Timeout**: 60 seconds ## Future Enhancements - Load balancing for multiple instances - Request queuing - Rate limiting per agent - Metrics and logging - Automatic failover