zhaoqingang
2025-01-02 b991b79b608e3b811399cb59b2776ce23ba6d1e0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from fastapi import Depends, APIRouter
from sqlalchemy.orm import Session
from starlette.responses import StreamingResponse
from app.api import get_current_user
from app.models import UserModel
from app.models.base_model import get_db
from app.models.v2.session_model import ChatDialogData
from app.service.v2.chat import service_chat_dialog
 
chat1_router = APIRouter()
 
 
@chat1_router.get("/chat_dialog")
async def api_chat_dialog(dialog: ChatDialogData, db: Session = Depends(get_db), current_user: UserModel = Depends(get_current_user)):
    return StreamingResponse(await service_chat_dialog(dialog.question, dialog.sessionId), media_type="text/event-stream")