mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-11-30 13:20:40 +03:00
add chat endpoint
This commit is contained in:
19
app/api/ml.py
Normal file
19
app/api/ml.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends, Form
|
||||
from fastapi.responses import StreamingResponse
|
||||
|
||||
from app.services.llm import get_llm_service
|
||||
from app.utils.logging import AppLogger
|
||||
|
||||
logger = AppLogger().get_logger()
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post('/chat/')
|
||||
async def chat(
|
||||
prompt: Annotated[str, Form()],
|
||||
llm_service = Depends(get_llm_service)
|
||||
):
|
||||
return StreamingResponse(llm_service.stream_chat(prompt), media_type="text/plain")
|
||||
Reference in New Issue
Block a user