Spaces:
Running
Running
| from fastapi import APIRouter | |
| from pydantic import BaseModel | |
| router = APIRouter() | |
| class ChatPayload(BaseModel): | |
| text: str | |
| context: dict = {} | |
| class GestureEvent(BaseModel): | |
| gesture: str | |
| confidence: float | |
| timestamp: float | |
| import asyncio | |
| from backend.services.agent_service import chat_with_agent, abort_generation | |
| async def chat(payload: ChatPayload): | |
| # Fire off chat as a background task so it doesn't block | |
| asyncio.create_task(chat_with_agent(payload.text, payload.context)) | |
| return {"status": "ok"} | |
| async def abort(): | |
| abort_generation() | |
| return {"status": "ok"} | |
| async def gesture_event(g: GestureEvent): | |
| return {"status": "ok"} | |