fix: 修复payload没有流式输出标志的问题
This commit is contained in:
@@ -317,6 +317,7 @@ class BotConfig:
|
||||
elif config.INNER_VERSION in SpecifierSet(">=0.0.1"):
|
||||
stable_item = ["name", "pri_in", "pri_out"]
|
||||
|
||||
stream_item = ["stream"]
|
||||
if config.INNER_VERSION in SpecifierSet(">=1.0.1"):
|
||||
stable_item.append("stream")
|
||||
|
||||
@@ -326,6 +327,10 @@ class BotConfig:
|
||||
# 如果 字段 属于计费项 且获取不到,那默认值是 0
|
||||
if i in pricing_item and i not in cfg_item:
|
||||
cfg_target[i] = 0
|
||||
|
||||
if i in stream_item and i not in cfg_item:
|
||||
cfg_target[i] = False
|
||||
|
||||
else:
|
||||
# 没有特殊情况则原样复制
|
||||
try:
|
||||
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
class EnvConfig:
|
||||
_instance = None
|
||||
|
||||
@@ -20,16 +21,16 @@ class EnvConfig:
|
||||
self.load_env()
|
||||
|
||||
def load_env(self):
|
||||
env_file = self.ROOT_DIR / '.env'
|
||||
env_file = self.ROOT_DIR / ".env"
|
||||
if env_file.exists():
|
||||
load_dotenv(env_file)
|
||||
|
||||
# 根据ENVIRONMENT变量加载对应的环境文件
|
||||
env_type = os.getenv('ENVIRONMENT', 'prod')
|
||||
if env_type == 'dev':
|
||||
env_file = self.ROOT_DIR / '.env.dev'
|
||||
elif env_type == 'prod':
|
||||
env_file = self.ROOT_DIR / '.env'
|
||||
env_type = os.getenv("ENVIRONMENT", "prod")
|
||||
if env_type == "dev":
|
||||
env_file = self.ROOT_DIR / ".env.dev"
|
||||
elif env_type == "prod":
|
||||
env_file = self.ROOT_DIR / ".env"
|
||||
|
||||
if env_file.exists():
|
||||
load_dotenv(env_file, override=True)
|
||||
@@ -43,13 +44,16 @@ class EnvConfig:
|
||||
def __getattr__(self, name):
|
||||
return self.get(name)
|
||||
|
||||
|
||||
# 创建全局实例
|
||||
env_config = EnvConfig()
|
||||
|
||||
|
||||
# 导出环境变量
|
||||
def get_env(key, default=None):
|
||||
return os.getenv(key, default)
|
||||
|
||||
|
||||
# 导出所有环境变量
|
||||
def get_all_env():
|
||||
return dict(os.environ)
|
||||
@@ -179,6 +179,10 @@ class LLM_request:
|
||||
# logger.debug(f"{logger_msg}发送请求到URL: {api_url}")
|
||||
# logger.info(f"使用模型: {self.model_name}")
|
||||
|
||||
# 流式输出标志
|
||||
if stream_mode:
|
||||
payload["stream"] = stream_mode
|
||||
|
||||
# 构建请求体
|
||||
if image_base64:
|
||||
payload = await self._build_payload(prompt, image_base64, image_format)
|
||||
|
||||
Reference in New Issue
Block a user