| | from fastapi import FastAPI |
| | from pydantic import BaseModel |
| |
|
| | app = FastAPI() |
| |
|
| | class InputData(BaseModel): |
| | input: str |
| |
|
| | @app.post("/agent") |
| | async def run_agent(data: InputData): |
| | input_text = data.input.lower() |
| |
|
| | if "heatwave" in input_text or "drought" in input_text: |
| | status = "CRITICAL" |
| | elif "rain" in input_text or "temperature" in input_text: |
| | status = "NORMAL" |
| | else: |
| | status = "UNKNOWN" |
| |
|
| | return { |
| | "output": { |
| | "status": status, |
| | "agent_response": f"Climate status identified as {status} based on input.", |
| | "summary": input_text |
| | } |
| | } |
| |
|
| | @app.get("/") |
| | async def root(): |
| | return {"message": "Climate Sensor Agent is alive"} |
| |
|