"""FastAPI router for medical scenario generation endpoints.This module defines the API routes related to creating and managing medicalsimulation scenarios. It includes endpoints for generating full scenariosbased on user-defined parameters and for retrieving available difficulty levels.Version: 4.3"""importloggingfromtypingimportDict,AnyfromfastapiimportAPIRouterfromagentsimportgenerate_medical_scenariofrommodelsimportFullScenario,ScenarioRequestfromconfigimportDIFFICULTY_LEVELS_CONFIG# Configure logginglogger=logging.getLogger(__name__)router=APIRouter(prefix="/scenarios",tags=["Scenarios"])
[docs]@router.post("/generate-scenario",response_model=FullScenario,summary="Generate a Full Medical Scenario")defgenerate_scenario_endpoint(request:ScenarioRequest)->FullScenario:"""Generates a complete medical scenario based on user specifications. This endpoint receives a request detailing the desired scenario and passes it to the scenario generation agent, which returns a fully structured scenario object. Args: request: An object containing the description, type, target audience, and difficulty level for the scenario. Returns: A complete, structured medical scenario object. """logger.info(f"Received request for the Medical Scenario Team: {request.model_dump()}")returngenerate_medical_scenario(request)
[docs]@router.get("/difficulty-levels",summary="Get Available Difficulty Levels")defget_difficulty_levels()->Dict[str,Any]:"""Retrieves the available difficulty levels for scenario generation."""returnDIFFICULTY_LEVELS_CONFIG