File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
main/xiaozhi-server/core/providers/llm/openai Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change
1
+ import httpx
1
2
import openai
2
3
from openai .types import CompletionUsage
3
4
from config .logger import setup_logging
@@ -16,6 +17,9 @@ def __init__(self, config):
16
17
self .base_url = config .get ("base_url" )
17
18
else :
18
19
self .base_url = config .get ("url" )
20
+ # 增加timeout的配置项,单位为秒
21
+ timeout = config .get ("timeout" , 300 )
22
+ self .timeout = int (timeout ) if timeout else 300
19
23
20
24
param_defaults = {
21
25
"max_tokens" : (500 , int ),
@@ -42,7 +46,7 @@ def __init__(self, config):
42
46
model_key_msg = check_model_key ("LLM" , self .api_key )
43
47
if model_key_msg :
44
48
logger .bind (tag = TAG ).error (model_key_msg )
45
- self .client = openai .OpenAI (api_key = self .api_key , base_url = self .base_url )
49
+ self .client = openai .OpenAI (api_key = self .api_key , base_url = self .base_url , timeout = httpx . Timeout ( self . timeout ) )
46
50
47
51
def response (self , session_id , dialogue , ** kwargs ):
48
52
try :
You can’t perform that action at this time.
0 commit comments