Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ from typing import Dict, List, Optional, Any, Callable
|
|
14 |
SI_KEYS = os.environ.get("SI_KEY", "").split(",")
|
15 |
MODEL_MAP_JSON = os.environ.get("MODEL_MAP")
|
16 |
API_BASE_URL = os.environ.get("API_BASE_URL", "https://api.siliconflow.cn/v1")
|
17 |
-
|
18 |
# 定义模型映射的类型
|
19 |
ModelMap = Dict[str, str]
|
20 |
# 定义 Key 余额的类型
|
@@ -118,7 +118,7 @@ async def forward_request(
|
|
118 |
yield chunk
|
119 |
return StreamingResponse(generate_response(), media_type="text/event-stream")
|
120 |
else:
|
121 |
-
async with httpx.AsyncClient() as client:
|
122 |
response = await client.post(
|
123 |
f"{API_BASE_URL}{url_path}", headers=headers, json=body
|
124 |
)
|
|
|
14 |
SI_KEYS = os.environ.get("SI_KEY", "").split(",")
|
15 |
MODEL_MAP_JSON = os.environ.get("MODEL_MAP")
|
16 |
API_BASE_URL = os.environ.get("API_BASE_URL", "https://api.siliconflow.cn/v1")
|
17 |
+
REQUEST_TIMEOUT=120
|
18 |
# 定义模型映射的类型
|
19 |
ModelMap = Dict[str, str]
|
20 |
# 定义 Key 余额的类型
|
|
|
118 |
yield chunk
|
119 |
return StreamingResponse(generate_response(), media_type="text/event-stream")
|
120 |
else:
|
121 |
+
async with httpx.AsyncClient(timeout=REQUEST_TIMEOUT) as client:
|
122 |
response = await client.post(
|
123 |
f"{API_BASE_URL}{url_path}", headers=headers, json=body
|
124 |
)
|