更新模型相关文件,移除自动添加语言指令的逻辑,改为直接使用系统提供的提示词;同时优化下拉菜单的显示位置和交互逻辑,提升用户体验。

This commit is contained in:
Zylan
2025-04-06 14:15:19 +08:00
parent 2f36d3b294
commit 72601d2a55
6 changed files with 154 additions and 900 deletions

View File

@@ -209,11 +209,8 @@ class AlibabaModel(BaseModel):
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)
# 检查系统提示词是否已包含语言设置指令
# 使用系统提供的系统提示词,不再自动添加语言指令
system_prompt = self.system_prompt
language = self.language or '中文'
if not any(phrase in system_prompt for phrase in ['Please respond in', '请用', '使用', '回答']):
system_prompt = f"{system_prompt}\n\n请务必使用{language}回答,无论问题是什么语言。即使在分析图像时也请使用{language}回答。"
# Prepare messages with image
messages = [

View File

@@ -195,14 +195,9 @@ class AnthropicModel(BaseModel):
'content-type': 'application/json'
}
# 获取系统提示词,确保包含语言设置
# 使用系统提供的系统提示词,不再自动添加语言指令
system_prompt = self.system_prompt
# 根据language参数设置回复语言
language = self.language or '中文'
if not any(phrase in system_prompt for phrase in ['Please respond in', '请用', '使用', '回答']):
system_prompt = f"{system_prompt}\n\n请务必使用{language}回答,无论问题是什么语言。即使在分析图像时也请使用{language}回答。这是最重要的指令。"
# 获取最大输出Token设置
max_tokens = 8192 # 默认值
if hasattr(self, 'max_tokens') and self.max_tokens:
@@ -227,7 +222,7 @@ class AnthropicModel(BaseModel):
},
{
'type': 'text',
'text': "请分析这个问题并提供详细的解决方案。如果你看到多个问题,请逐一解决。请务必使用中文回答。"
'text': "请分析这个问题并提供详细的解决方案。如果你看到多个问题,请逐一解决。"
}
]
}]

View File

@@ -66,11 +66,8 @@ class DeepSeekModel(BaseModel):
base_url="https://api.deepseek.com"
)
# 添加系统语言指令
# 使用系统提供的系统提示词,不再自动添加语言指令
system_prompt = self.system_prompt
language = self.language or '中文'
if not any(phrase in system_prompt for phrase in ['Please respond in', '请用', '使用', '回答']):
system_prompt = f"{system_prompt}\n\n请务必使用{language}回答。"
# 构建请求参数
params = {
@@ -244,11 +241,8 @@ class DeepSeekModel(BaseModel):
base_url="https://api.deepseek.com"
)
# 检查系统提示词是否已包含语言设置指令
# 使用系统提供的系统提示词,不再自动添加语言指令
system_prompt = self.system_prompt
language = self.language or '中文'
if not any(phrase in system_prompt for phrase in ['Please respond in', '请用', '使用', '回答']):
system_prompt = f"{system_prompt}\n\n请务必使用{language}回答,无论问题是什么语言。即使在分析图像时也请使用{language}回答。"
# 构建请求参数
params = {

View File

@@ -126,11 +126,8 @@ class OpenAIModel(BaseModel):
# Initialize OpenAI client
client = OpenAI(api_key=self.api_key)
# 检查系统提示词是否已包含语言设置指令
# 使用系统提供的系统提示词,不再自动添加语言指令
system_prompt = self.system_prompt
language = self.language or '中文'
if not any(phrase in system_prompt for phrase in ['Please respond in', '请用', '使用', '回答']):
system_prompt = f"{system_prompt}\n\n请务必使用{language}回答,无论问题是什么语言。即使在分析图像时也请使用{language}回答。"
# Prepare messages with image
messages = [