mirror of
https://github.com/Usagi-org/ai-goofish-monitor.git
synced 2025-11-25 11:29:41 +08:00
feat: 添加ENABLE_JSON_MODE配置以解决模型不支持JSON模式的问题
- 在.env.example中添加ENABLE_JSON_MODE配置变量 - 在src/config.py中添加ENABLE_JSON_MODE环境变量支持 - 修改get_ai_request_params函数,当ENABLE_JSON_MODE为false时移除response_format参数 - 解决某些AI模型不支持JSON模式导致的调用失败问题 Co-authored-by: rainsfly <dingyufei615@users.noreply.github.com>
This commit is contained in:
@@ -56,6 +56,9 @@ AI_DEBUG_MODE=false
|
||||
# 是否启用enable_thinking参数 (true/false)。某些AI模型需要此参数,而有些则不支持。
|
||||
ENABLE_THINKING=false
|
||||
|
||||
# 是否启用JSON模式 (true/false)。某些AI模型不支持JSON模式,设置为false可关闭此功能。
|
||||
ENABLE_JSON_MODE=true
|
||||
|
||||
# 服务端口自定义 不配置默认8000
|
||||
SERVER_PORT=8000
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ RUNNING_IN_DOCKER = os.getenv("RUNNING_IN_DOCKER", "false").lower() == "true"
|
||||
AI_DEBUG_MODE = os.getenv("AI_DEBUG_MODE", "false").lower() == "true"
|
||||
SKIP_AI_ANALYSIS = os.getenv("SKIP_AI_ANALYSIS", "false").lower() == "true"
|
||||
ENABLE_THINKING = os.getenv("ENABLE_THINKING", "false").lower() == "true"
|
||||
ENABLE_JSON_MODE = os.getenv("ENABLE_JSON_MODE", "true").lower() == "true"
|
||||
|
||||
# --- Headers ---
|
||||
IMAGE_DOWNLOAD_HEADERS = {
|
||||
@@ -91,4 +92,9 @@ def get_ai_request_params(**kwargs):
|
||||
"""
|
||||
if ENABLE_THINKING:
|
||||
kwargs["extra_body"] = {"enable_thinking": False}
|
||||
|
||||
# 如果禁用JSON模式,移除response_format参数
|
||||
if not ENABLE_JSON_MODE and "response_format" in kwargs:
|
||||
del kwargs["response_format"]
|
||||
|
||||
return kwargs
|
||||
|
||||
Reference in New Issue
Block a user