Просмотр исходного кода

fix(env): update STREAMING_TIMEOUT default value to 300 seconds

CaIon 6 месяцев назад
Родитель
Сommit
17bab355e4
6 измененных файлов с 5 добавлено и 9 удалено
  1. 1 1
      .env.example
  2. 1 1
      README.en.md
  3. 1 1
      README.md
  4. 1 1
      common/init.go
  5. 1 1
      docker-compose.yml
  6. 0 4
      relay/helper/stream_scanner.go

+ 1 - 1
.env.example

@@ -47,7 +47,7 @@
 # 所有请求超时时间,单位秒,默认为0,表示不限制
 # RELAY_TIMEOUT=0
 # 流模式无响应超时时间,单位秒,如果出现空补全可以尝试改为更大值
-# STREAMING_TIMEOUT=120
+# STREAMING_TIMEOUT=300
 
 # Gemini 识别图片 最大图片数量
 # GEMINI_VISION_MAX_IMAGE_NUM=16

+ 1 - 1
README.en.md

@@ -100,7 +100,7 @@ This version supports multiple models, please refer to [API Documentation-Relay
 For detailed configuration instructions, please refer to [Installation Guide-Environment Variables Configuration](https://docs.newapi.pro/installation/environment-variables):
 
 - `GENERATE_DEFAULT_TOKEN`: Whether to generate initial tokens for newly registered users, default is `false`
-- `STREAMING_TIMEOUT`: Streaming response timeout, default is 120 seconds
+- `STREAMING_TIMEOUT`: Streaming response timeout, default is 300 seconds
 - `DIFY_DEBUG`: Whether to output workflow and node information for Dify channels, default is `true`
 - `FORCE_STREAM_OPTION`: Whether to override client stream_options parameter, default is `true`
 - `GET_MEDIA_TOKEN`: Whether to count image tokens, default is `true`

+ 1 - 1
README.md

@@ -100,7 +100,7 @@ New API提供了丰富的功能,详细特性请参考[特性说明](https://do
 详细配置说明请参考[安装指南-环境变量配置](https://docs.newapi.pro/installation/environment-variables):
 
 - `GENERATE_DEFAULT_TOKEN`:是否为新注册用户生成初始令牌,默认为 `false`
-- `STREAMING_TIMEOUT`:流式回复超时时间,默认120秒
+- `STREAMING_TIMEOUT`:流式回复超时时间,默认300秒
 - `DIFY_DEBUG`:Dify渠道是否输出工作流和节点信息,默认 `true`
 - `FORCE_STREAM_OPTION`:是否覆盖客户端stream_options参数,默认 `true`
 - `GET_MEDIA_TOKEN`:是否统计图片token,默认 `true`

+ 1 - 1
common/init.go

@@ -101,7 +101,7 @@ func InitEnv() {
 }
 
 func initConstantEnv() {
-	constant.StreamingTimeout = GetEnvOrDefault("STREAMING_TIMEOUT", 120)
+	constant.StreamingTimeout = GetEnvOrDefault("STREAMING_TIMEOUT", 300)
 	constant.DifyDebug = GetEnvOrDefaultBool("DIFY_DEBUG", true)
 	constant.MaxFileDownloadMB = GetEnvOrDefault("MAX_FILE_DOWNLOAD_MB", 20)
 	// ForceStreamOption 覆盖请求参数,强制返回usage信息

+ 1 - 1
docker-compose.yml

@@ -16,7 +16,7 @@ services:
       - REDIS_CONN_STRING=redis://redis
       - TZ=Asia/Shanghai
       - ERROR_LOG_ENABLED=true # 是否启用错误日志记录
-    #      - STREAMING_TIMEOUT=120  # 流模式无响应超时时间,单位秒,默认120秒,如果出现空补全可以尝试改为更大值
+    #      - STREAMING_TIMEOUT=300  # 流模式无响应超时时间,单位秒,默认120秒,如果出现空补全可以尝试改为更大值
     #      - SESSION_SECRET=random_string  # 多机部署时设置,必须修改这个随机字符串!!!!!!!
     #      - NODE_TYPE=slave  # Uncomment for slave node in multi-node deployment
     #      - SYNC_FREQUENCY=60  # Uncomment if regular database syncing is needed

+ 0 - 4
relay/helper/stream_scanner.go

@@ -39,10 +39,6 @@ func StreamScannerHandler(c *gin.Context, resp *http.Response, info *relaycommon
 	}()
 
 	streamingTimeout := time.Duration(constant.StreamingTimeout) * time.Second
-	if strings.HasPrefix(info.UpstreamModelName, "o") {
-		// twice timeout for thinking model
-		streamingTimeout *= 2
-	}
 
 	var (
 		stopChan   = make(chan bool, 3) // 增加缓冲区避免阻塞