mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
format code
This commit is contained in:
parent
61ba8cc12c
commit
6f2db272c4
@ -11,9 +11,6 @@ logger = AppLogger().get_logger()
|
|||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
@router.post('/chat/')
|
@router.post("/chat/")
|
||||||
async def chat(
|
async def chat(prompt: Annotated[str, Form()], llm_service=Depends(get_llm_service)):
|
||||||
prompt: Annotated[str, Form()],
|
return StreamingResponse(llm_service.stream_chat(prompt), media_type="text/plain")
|
||||||
llm_service = Depends(get_llm_service)
|
|
||||||
):
|
|
||||||
return StreamingResponse(llm_service.stream_chat(prompt), media_type="text/plain")
|
|
||||||
|
@ -14,7 +14,9 @@ async def chat_with_endpoint():
|
|||||||
|
|
||||||
print("\nModel: ", end="", flush=True)
|
print("\nModel: ", end="", flush=True)
|
||||||
try:
|
try:
|
||||||
async with client.stream("POST", API_URL, data={"prompt": prompt}, timeout=60) as response:
|
async with client.stream(
|
||||||
|
"POST", API_URL, data={"prompt": prompt}, timeout=60
|
||||||
|
) as response:
|
||||||
async for chunk in response.aiter_lines():
|
async for chunk in response.aiter_lines():
|
||||||
if not chunk:
|
if not chunk:
|
||||||
continue
|
continue
|
||||||
@ -28,4 +30,4 @@ async def chat_with_endpoint():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
anyio.run(chat_with_endpoint)
|
anyio.run(chat_with_endpoint)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user