from fastapi import FastAPI, UploadFile, File, Form from fastapi.responses import JSONResponse from app.pipeline import plant_intelligence_pipeline app = FastAPI( title=" Plant Intelligence AI", description="Hybrid Plant Identifier + Reasoning Assistant", version="1.0.0", ) @app.get("/") def home(): return {"message": "Welcome to the Plant Intelligence AI "} @app.post("/analyze") async def analyze(file: UploadFile = File(...), query: str = Form("")): try: image_bytes = await file.read() result = plant_intelligence_pipeline(image_bytes, user_query=query) return JSONResponse(result) except Exception as e: return JSONResponse({"error": str(e)}, status_code=500)