mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-06-02 14:19:55 +08:00
feat: 新增请求超时配置及优化模型列表接口api_key获取方式
1. 新增功能:
- 在`.env.example`中添加`TIME_OUT=300`配置项(包含中文注释)
- 在`Settings`类中增加`TIME_OUT`字段(读取自`DEFAULT_TIMEOUT`)
2. 优化内容:
- 生成配置:
* 为`GenerationConfig`设置默认温度/TOP_P/TOP_K值
* 移除`maxOutputTokens`默认值,改为可选传递
- OpenAI请求:
* 移除`max_tokens`默认值
* 只有当`max_tokens`有值时才添加到请求payload
- 日志优化:
* 注释掉`stream_optimizer.py`中部分调试日志
3. 模型列表接口api_key获取方式
This commit is contained in:
@@ -107,15 +107,15 @@ class StreamOptimizer:
|
||||
|
||||
# 计算智能延迟时间
|
||||
delay = self.calculate_delay(len(text))
|
||||
if self.logger:
|
||||
self.logger.info(f"Text length: {len(text)}, delay: {delay:.4f}s")
|
||||
# if self.logger:
|
||||
# self.logger.info(f"Text length: {len(text)}, delay: {delay:.4f}s")
|
||||
|
||||
# 根据文本长度决定输出方式
|
||||
if len(text) >= self.long_text_threshold:
|
||||
# 长文本:分块输出
|
||||
chunks = self.split_text_into_chunks(text)
|
||||
if self.logger:
|
||||
self.logger.info(f"Long text: splitting into {len(chunks)} chunks")
|
||||
# if self.logger:
|
||||
# self.logger.info(f"Long text: splitting into {len(chunks)} chunks")
|
||||
for chunk_text in chunks:
|
||||
chunk_response = create_response_chunk(chunk_text)
|
||||
yield format_chunk(chunk_response)
|
||||
|
||||
Reference in New Issue
Block a user