File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,25 @@ client = ZhipuAI(
4444 api_key = " " , # 填写您的 APIKey
4545)
4646```
47+ ### 客户端网络链接配置
48+ 在` core/_http_client.py ` 中,可以配置网络链接的超时时间,重试次数,限制等参数
49+ ``` python
50+ # 通过 `Timeout` 控制接口`connect` 和 `read` 超时时间,默认为`timeout=300.0, connect=8.0`
51+ ZHIPUAI_DEFAULT_TIMEOUT = httpx.Timeout(timeout = 300.0 , connect = 8.0 )
52+ # 通过 `retry` 参数控制重试次数,默认为3次
53+ ZHIPUAI_DEFAULT_MAX_RETRIES = 3
54+ # 通过 `Limits` 控制最大连接数和保持连接数,默认为`max_connections=50, max_keepalive_connections=10`
55+ ZHIPUAI_DEFAULT_LIMITS = httpx.Limits(max_connections = 50 , max_keepalive_connections = 10 )
56+
57+ ```
58+ 同样在` ZhipuAI ` 入参中可以配置
59+ ``` python
60+ client = ZhipuAI(
61+ timeout = httpx.Timeout(timeout = 300.0 , connect = 8.0 ),
62+ max_retries = 3 ,
63+ )
64+ ```
65+
4766
4867### 同步调用
4968
Original file line number Diff line number Diff line change 5656
5757from httpx ._config import DEFAULT_TIMEOUT_CONFIG as HTTPX_DEFAULT_TIMEOUT
5858RAW_RESPONSE_HEADER = "X-Stainless-Raw-Response"
59+ # 通过 `Timeout` 控制接口`connect` 和 `read` 超时时间,默认为`timeout=300.0, connect=8.0`
5960ZHIPUAI_DEFAULT_TIMEOUT = httpx .Timeout (timeout = 300.0 , connect = 8.0 )
61+ # 通过 `retry` 参数控制重试次数,默认为3次
6062ZHIPUAI_DEFAULT_MAX_RETRIES = 3
63+ # 通过 `Limits` 控制最大连接数和保持连接数,默认为`max_connections=50, max_keepalive_connections=10`
6164ZHIPUAI_DEFAULT_LIMITS = httpx .Limits (max_connections = 50 , max_keepalive_connections = 10 )
6265
6366INITIAL_RETRY_DELAY = 0.5
You can’t perform that action at this time.
0 commit comments