From 32f57d9a22403105ac48424f0a814712bedb49a7 Mon Sep 17 00:00:00 2001 From: Danil Parunin 5f1b81b8-4f5d-11e8-9c2d-fa7ae01bbebc Date: Sat, 6 Dec 2025 14:58:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chat.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 chat.py diff --git a/chat.py b/chat.py new file mode 100644 index 0000000..cfec6cb --- /dev/null +++ b/chat.py @@ -0,0 +1,13 @@ +from fastapi import APIRouter, HTTPException +from app.models.schemas import ChatRequest, ChatResponse +from app.services.gigachat import call_gigachat + +router = APIRouter() + +@router.post("/chat", response_model=ChatResponse) +async def chat_endpoint(payload: ChatRequest): + try: + reply = await call_gigachat(payload.message, payload.agent.value) + return ChatResponse(reply=reply, agent_used=payload.agent.value) + except Exception as exc: + raise HTTPException(status_code=502, detail=f"GigaChat error: {str(exc)}") \ No newline at end of file