mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-06 05:09:09 +08:00
parent
4a62bb6ad7
commit
e0dbd2d2db
@ -9,6 +9,7 @@ import {
|
|||||||
isGPT5SeriesModel,
|
isGPT5SeriesModel,
|
||||||
isGrokReasoningModel,
|
isGrokReasoningModel,
|
||||||
isNotSupportSystemMessageModel,
|
isNotSupportSystemMessageModel,
|
||||||
|
isOpenAIReasoningModel,
|
||||||
isQwenAlwaysThinkModel,
|
isQwenAlwaysThinkModel,
|
||||||
isQwenMTModel,
|
isQwenMTModel,
|
||||||
isQwenReasoningModel,
|
isQwenReasoningModel,
|
||||||
@ -146,7 +147,7 @@ export class OpenAIAPIClient extends OpenAIBaseClient<
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
// Don't disable reasoning for models that require it
|
// Don't disable reasoning for models that require it
|
||||||
if (isGrokReasoningModel(model)) {
|
if (isGrokReasoningModel(model) || isOpenAIReasoningModel(model)) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
return { reasoning: { enabled: false, exclude: true } }
|
return { reasoning: { enabled: false, exclude: true } }
|
||||||
@ -524,12 +525,13 @@ export class OpenAIAPIClient extends OpenAIBaseClient<
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1. 处理系统消息
|
// 1. 处理系统消息
|
||||||
let systemMessage = { role: 'system', content: assistant.prompt || '' }
|
const systemMessage = { role: 'system', content: assistant.prompt || '' }
|
||||||
|
|
||||||
if (isSupportedReasoningEffortOpenAIModel(model)) {
|
if (isSupportedReasoningEffortOpenAIModel(model)) {
|
||||||
systemMessage = {
|
if (isSupportDeveloperRoleProvider(this.provider)) {
|
||||||
role: isSupportDeveloperRoleProvider(this.provider) ? 'developer' : 'system',
|
systemMessage.role = 'developer'
|
||||||
content: `Formatting re-enabled${systemMessage ? '\n' + systemMessage.content : ''}`
|
} else {
|
||||||
|
systemMessage.role = 'system'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -292,6 +292,7 @@ export const CLAUDE_SUPPORTED_WEBSEARCH_REGEX = new RegExp(
|
|||||||
// 模型类型到支持的reasoning_effort的映射表
|
// 模型类型到支持的reasoning_effort的映射表
|
||||||
export const MODEL_SUPPORTED_REASONING_EFFORT: ReasoningEffortConfig = {
|
export const MODEL_SUPPORTED_REASONING_EFFORT: ReasoningEffortConfig = {
|
||||||
default: ['low', 'medium', 'high'] as const,
|
default: ['low', 'medium', 'high'] as const,
|
||||||
|
o: ['low', 'medium', 'high'] as const,
|
||||||
gpt5: ['minimal', 'low', 'medium', 'high'] as const,
|
gpt5: ['minimal', 'low', 'medium', 'high'] as const,
|
||||||
grok: ['low', 'high'] as const,
|
grok: ['low', 'high'] as const,
|
||||||
gemini: ['low', 'medium', 'high', 'auto'] as const,
|
gemini: ['low', 'medium', 'high', 'auto'] as const,
|
||||||
@ -307,7 +308,8 @@ export const MODEL_SUPPORTED_REASONING_EFFORT: ReasoningEffortConfig = {
|
|||||||
// 模型类型到支持选项的映射表
|
// 模型类型到支持选项的映射表
|
||||||
export const MODEL_SUPPORTED_OPTIONS: ThinkingOptionConfig = {
|
export const MODEL_SUPPORTED_OPTIONS: ThinkingOptionConfig = {
|
||||||
default: ['off', ...MODEL_SUPPORTED_REASONING_EFFORT.default] as const,
|
default: ['off', ...MODEL_SUPPORTED_REASONING_EFFORT.default] as const,
|
||||||
gpt5: ['off', ...MODEL_SUPPORTED_REASONING_EFFORT.gpt5] as const,
|
o: MODEL_SUPPORTED_REASONING_EFFORT.o,
|
||||||
|
gpt5: [...MODEL_SUPPORTED_REASONING_EFFORT.gpt5] as const,
|
||||||
grok: MODEL_SUPPORTED_REASONING_EFFORT.grok,
|
grok: MODEL_SUPPORTED_REASONING_EFFORT.grok,
|
||||||
gemini: ['off', ...MODEL_SUPPORTED_REASONING_EFFORT.gemini] as const,
|
gemini: ['off', ...MODEL_SUPPORTED_REASONING_EFFORT.gemini] as const,
|
||||||
gemini_pro: MODEL_SUPPORTED_REASONING_EFFORT.gemini_pro,
|
gemini_pro: MODEL_SUPPORTED_REASONING_EFFORT.gemini_pro,
|
||||||
@ -320,28 +322,28 @@ export const MODEL_SUPPORTED_OPTIONS: ThinkingOptionConfig = {
|
|||||||
} as const
|
} as const
|
||||||
|
|
||||||
export const getThinkModelType = (model: Model): ThinkingModelType => {
|
export const getThinkModelType = (model: Model): ThinkingModelType => {
|
||||||
|
let thinkingModelType: ThinkingModelType = 'default'
|
||||||
if (isGPT5SeriesModel(model)) {
|
if (isGPT5SeriesModel(model)) {
|
||||||
return 'gpt5'
|
thinkingModelType = 'gpt5'
|
||||||
}
|
} else if (isSupportedReasoningEffortOpenAIModel(model)) {
|
||||||
if (isSupportedThinkingTokenGeminiModel(model)) {
|
thinkingModelType = 'o'
|
||||||
|
} else if (isSupportedThinkingTokenGeminiModel(model)) {
|
||||||
if (GEMINI_FLASH_MODEL_REGEX.test(model.id)) {
|
if (GEMINI_FLASH_MODEL_REGEX.test(model.id)) {
|
||||||
return 'gemini'
|
thinkingModelType = 'gemini'
|
||||||
} else {
|
} else {
|
||||||
return 'gemini_pro'
|
thinkingModelType = 'gemini_pro'
|
||||||
}
|
}
|
||||||
}
|
} else if (isSupportedReasoningEffortGrokModel(model)) thinkingModelType = 'grok'
|
||||||
if (isSupportedReasoningEffortGrokModel(model)) return 'grok'
|
else if (isSupportedThinkingTokenQwenModel(model)) {
|
||||||
if (isSupportedThinkingTokenQwenModel(model)) {
|
|
||||||
if (isQwenAlwaysThinkModel(model)) {
|
if (isQwenAlwaysThinkModel(model)) {
|
||||||
return 'qwen_thinking'
|
thinkingModelType = 'qwen_thinking'
|
||||||
}
|
}
|
||||||
return 'qwen'
|
thinkingModelType = 'qwen'
|
||||||
}
|
} else if (isSupportedThinkingTokenDoubaoModel(model)) thinkingModelType = 'doubao'
|
||||||
if (isSupportedThinkingTokenDoubaoModel(model)) return 'doubao'
|
else if (isSupportedThinkingTokenHunyuanModel(model)) thinkingModelType = 'hunyuan'
|
||||||
if (isSupportedThinkingTokenHunyuanModel(model)) return 'hunyuan'
|
else if (isSupportedReasoningEffortPerplexityModel(model)) thinkingModelType = 'perplexity'
|
||||||
if (isSupportedReasoningEffortPerplexityModel(model)) return 'perplexity'
|
else if (isSupportedThinkingTokenZhipuModel(model)) thinkingModelType = 'zhipu'
|
||||||
if (isSupportedThinkingTokenZhipuModel(model)) return 'zhipu'
|
return thinkingModelType
|
||||||
return 'default'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFunctionCallingModel(model?: Model): boolean {
|
export function isFunctionCallingModel(model?: Model): boolean {
|
||||||
|
|||||||
@ -56,6 +56,7 @@ export type ReasoningEffortOption = NonNullable<OpenAI.ReasoningEffort> | 'auto'
|
|||||||
export type ThinkingOption = ReasoningEffortOption | 'off'
|
export type ThinkingOption = ReasoningEffortOption | 'off'
|
||||||
export type ThinkingModelType =
|
export type ThinkingModelType =
|
||||||
| 'default'
|
| 'default'
|
||||||
|
| 'o'
|
||||||
| 'gpt5'
|
| 'gpt5'
|
||||||
| 'grok'
|
| 'grok'
|
||||||
| 'gemini'
|
| 'gemini'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user