gg
This commit is contained in:
0
app/api/__init__.py
Normal file
0
app/api/__init__.py
Normal file
BIN
app/api/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
app/api/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
app/api/__pycache__/chat.cpython-311.pyc
Normal file
BIN
app/api/__pycache__/chat.cpython-311.pyc
Normal file
Binary file not shown.
13
app/api/chat.py
Normal file
13
app/api/chat.py
Normal file
@@ -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)}")
|
||||
Reference in New Issue
Block a user