diff --git a/src/renderer/src/aiCore/prepareParams/modelCapabilities.ts b/src/renderer/src/aiCore/prepareParams/modelCapabilities.ts index 4a3c3f4bbf..b6e4b25843 100644 --- a/src/renderer/src/aiCore/prepareParams/modelCapabilities.ts +++ b/src/renderer/src/aiCore/prepareParams/modelCapabilities.ts @@ -85,6 +85,19 @@ export function supportsLargeFileUpload(model: Model): boolean { }) } +/** + * 检查模型是否支持TopP + */ +export function supportsTopP(model: Model): boolean { + const provider = getProviderByModel(model) + + if (provider?.type === 'anthropic' || model?.endpoint_type === 'anthropic') { + return false + } + + return true +} + /** * 获取提供商特定的文件大小限制 */ diff --git a/src/renderer/src/aiCore/prepareParams/parameterBuilder.ts b/src/renderer/src/aiCore/prepareParams/parameterBuilder.ts index d3fa1cb654..397c481cf3 100644 --- a/src/renderer/src/aiCore/prepareParams/parameterBuilder.ts +++ b/src/renderer/src/aiCore/prepareParams/parameterBuilder.ts @@ -34,6 +34,7 @@ import { setupToolsConfig } from '../utils/mcp' import { buildProviderOptions } from '../utils/options' import { getAnthropicThinkingBudget } from '../utils/reasoning' import { buildProviderBuiltinWebSearchConfig } from '../utils/websearch' +import { supportsTopP } from './modelCapabilities' import { getTemperature, getTopP } from './modelParameters' const logger = loggerService.withContext('parameterBuilder') @@ -176,20 +177,27 @@ export async function buildStreamTextParams( messages: sdkMessages, maxOutputTokens: maxTokens, temperature: getTemperature(assistant, model), - topP: getTopP(assistant, model), abortSignal: options.requestOptions?.signal, headers: options.requestOptions?.headers, providerOptions, stopWhen: stepCountIs(20), maxRetries: 0 } + + if (supportsTopP(model)) { + params.topP = getTopP(assistant, model) + } + if (tools) { params.tools = tools } + if (assistant.prompt) { params.system = await replacePromptVariables(assistant.prompt, model.name) } + logger.debug('params', params) + return { params, modelId: model.id,