feat: 项目初始化、完成基本流式传输和语音识别功能

This commit is contained in:
2025-06-28 19:21:46 +08:00
commit d6f9cd7aed
91 changed files with 7827 additions and 0 deletions

View File

View File

@@ -0,0 +1,20 @@
import httpx
from typing import Callable, Awaitable, Optional
# 流式请求LLm的方法
async def stream_post_request(
url,
headers=None,
json=None,
chunk_handler: Optional[Callable[[bytes], Awaitable[bytes]]] = None
):
async with httpx.AsyncClient(http2=True) as client:
async with client.stream(
method="POST", url=url, headers=headers, json=json
) as response:
async for chunk in response.aiter_bytes():
if chunk_handler:
# 支持异步处理
chunk = await chunk_handler(chunk)
yield chunk