实现基于 token 长度的简单规则路由服务: - FastAPI 基础服务 (/v1/chat/completions) - 根据 token 长度自动选择模型 (gpt-3.5/gpt-4o-mini/gpt-4o) - 成本追踪和统计 (/stats) - 健康检查端点 (/health) - 总计 224 行代码
9 lines
140 B
Plaintext
9 lines
140 B
Plaintext
fastapi>=0.104.0
|
|
uvicorn[standard]>=0.24.0
|
|
pydantic>=2.5.0
|
|
openai>=1.6.0
|
|
tiktoken>=0.5.0
|
|
httpx>=0.25.0
|
|
pytest>=7.4.0
|
|
pytest-asyncio>=0.21.0
|