File size: 2,152 Bytes
d28f1ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""Routes for listing available models and agents."""
from fastapi import APIRouter, Depends
from core.security import get_current_user
from domain.models import ModelsListResponse, AgentsListResponse, ModelInfo, AgentInfo
from services.llm_service import llm_service
from services.agent_registry import agent_registry

router = APIRouter(tags=["Models & Agents"])


@router.get("/models", response_model=ModelsListResponse)
async def list_models(
    current_user: dict = Depends(get_current_user)
) -> ModelsListResponse:
    """
    List all available LLM models.
    
    Returns information about all supported models from OpenAI and Mistral AI,
    including their capabilities and context windows.
    
    Args:
        current_user: Authenticated user (JWT required)
        
    Returns:
        List of available models with metadata
    """
    models_data = llm_service.list_available_models()
    models = [ModelInfo(**model) for model in models_data]
    
    return ModelsListResponse(
        models=models,
        total=len(models)
    )


@router.get("/agents", response_model=AgentsListResponse)
async def list_agents(
    current_user: dict = Depends(get_current_user)
) -> AgentsListResponse:
    """
    List all available agent types.
    
    Returns information about all registered agent types and their availability.
    
    Args:
        current_user: Authenticated user (JWT required)
        
    Returns:
        List of available agents with metadata
    """
    agents_data = agent_registry.list_agents()
    agents = [AgentInfo(**agent) for agent in agents_data]
    
    return AgentsListResponse(
        agents=agents,
        total=len(agents)
    )


@router.get("/health")
async def health_check():
    """
    Health check endpoint (no authentication required).
    
    Returns:
        API health status
    """
    from config import settings
    from datetime import datetime
    
    return {
        "status": "healthy",
        "version": settings.api_version,
        "title": settings.api_title,
        "environment": settings.environment,
        "timestamp": datetime.utcnow().isoformat()
    }