Spaces:
Sleeping
Sleeping
| from typing import Any, Dict, Optional | |
| from fastapi import APIRouter, HTTPException | |
| from pydantic import BaseModel, Field | |
| from app.db.supabase import SupabaseConfigError | |
| from app.services.recommendation_service import recommend_pois | |
| router = APIRouter(prefix="/chat", tags=["Chat"]) | |
| class RecommendRequest(BaseModel): | |
| query: str = Field(..., min_length=1) | |
| location: Optional[Dict[str, Any]] = None | |
| def recommend(payload: RecommendRequest): | |
| try: | |
| return recommend_pois(payload.query, payload.location) | |
| except SupabaseConfigError as exc: | |
| raise HTTPException(status_code=500, detail=str(exc)) from exc | |
| except Exception as exc: | |
| raise HTTPException(status_code=500, detail=f"Recommendation failed: {exc}") from exc | |