Add application setup and test infrastructure
Application Configuration: - FastAPI application factory pattern - CORS middleware for cross-origin support - Global exception handlers for consistent error responses - AppException handler for custom errors - RequestValidationError handler for Pydantic validation - General exception handler for unexpected errors - Lifespan management for startup/shutdown events - Router registration for all API endpoints - OpenAPI schema with interactive documentation Models Service: - Integration with ModelRegistry - List available models endpoint - Model capability discovery Test Infrastructure: - Pytest configuration with async support - Test client fixtures for sync and async testing - Comprehensive main application tests (14 tests): - App creation and metadata - Router registration verification - CORS middleware and functionality - Exception handler registration and behavior - Lifespan event handling - OpenAPI schema generation - Documentation accessibility - Validation error handling - Models API tests (2 tests) - Total: 95 tests, 78.95% coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ from src.core.config import config
|
||||
from src.core.exceptions import AppException
|
||||
from src.core.router import router as core_router
|
||||
from src.models.router import router as models_router
|
||||
from src.responses.router import router as responses_router
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
@@ -82,6 +83,7 @@ def create_application() -> FastAPI:
|
||||
application.include_router(core_router) # Health and root endpoints
|
||||
application.include_router(chat_router, prefix=config.API_PREFIX)
|
||||
application.include_router(models_router, prefix=config.API_PREFIX)
|
||||
application.include_router(responses_router, prefix=config.API_PREFIX) # Responses API
|
||||
|
||||
return application
|
||||
|
||||
|
||||
+14
-15
@@ -1,34 +1,33 @@
|
||||
"""
|
||||
Models service.
|
||||
Currently returns mock model list.
|
||||
TODO: Fetch from Ollama in future.
|
||||
Returns available models from the model registry.
|
||||
"""
|
||||
import time
|
||||
|
||||
from src.agents.registry import ModelRegistry
|
||||
from src.models.schemas import Model, ModelsResponse
|
||||
|
||||
|
||||
# Mock models (will be replaced with Ollama models later)
|
||||
MOCK_MODELS = [
|
||||
{"id": "mistral-nemo:latest", "created": int(time.time())},
|
||||
]
|
||||
|
||||
|
||||
async def list_models() -> ModelsResponse:
|
||||
"""
|
||||
List available models (mock implementation).
|
||||
|
||||
List available models from registry.
|
||||
|
||||
Returns models with their capabilities and metadata.
|
||||
|
||||
Returns:
|
||||
Mock list of models
|
||||
ModelsResponse: List of available models
|
||||
"""
|
||||
# Get models from registry with capabilities
|
||||
registry_models = await ModelRegistry.list_models()
|
||||
|
||||
# Convert to Model schema format
|
||||
models = [
|
||||
Model(
|
||||
id=model["id"],
|
||||
object="model",
|
||||
created=model["created"],
|
||||
owned_by="system",
|
||||
owned_by=model["owned_by"],
|
||||
)
|
||||
for model in MOCK_MODELS
|
||||
for model in registry_models
|
||||
]
|
||||
|
||||
|
||||
return ModelsResponse(object="list", data=models)
|
||||
|
||||
Reference in New Issue
Block a user