from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class InputData(BaseModel): input: str @app.post("/agent") async def run_agent(data: InputData): text = data.input.lower() if "flood" in text or "storm" in text: impact = { "estimated_gdp_loss_percent": 1.5, "sectors_affected": ["agriculture", "logistics", "insurance"], "recovery_time_months": 6, "notes": "Flooding likely to disrupt food supply chains and increase insurance claims." } elif "heatwave" in text or "wildfire" in text: impact = { "estimated_gdp_loss_percent": 0.8, "sectors_affected": ["energy", "healthcare", "construction"], "recovery_time_months": 4, "notes": "Heatwaves increase healthcare load and reduce construction productivity." } elif "pollution" in text or "emissions" in text: impact = { "estimated_gdp_loss_percent": 0.3, "sectors_affected": ["manufacturing", "public health"], "recovery_time_months": 2, "notes": "Pollution regulations may temporarily reduce industrial output but save long-term healthcare costs." } else: impact = { "estimated_gdp_loss_percent": 0.1, "sectors_affected": ["general"], "recovery_time_months": 1, "notes": "No significant economic disruption detected. Monitoring advised." } return { "output": { "economic_impact_forecast": impact, "summary": f"Forecast generated for scenario: '{data.input[:50]}...'" } } @app.get("/") async def healthcheck(): return {"message": "Economic Forecast Agent is alive"}