mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-24 14:40:22 +09:00
修改: app/api/bedrock.ts
修改: app/utils.ts
This commit is contained in:
parent
e3c18bb123
commit
d55c752e1e
@ -39,6 +39,14 @@ export interface ConverseRequest {
|
|||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function supportsToolUse(modelId: string): boolean {
|
||||||
|
// llama和mistral模型不支持工具调用
|
||||||
|
return (
|
||||||
|
modelId.toLowerCase().includes("claude-3") &&
|
||||||
|
modelId.toLowerCase().includes("claude-3-5")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function formatRequestBody(
|
function formatRequestBody(
|
||||||
request: ConverseRequest,
|
request: ConverseRequest,
|
||||||
): ConverseStreamCommandInput {
|
): ConverseStreamCommandInput {
|
||||||
@ -96,15 +104,15 @@ function formatRequestBody(
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
// 添加工具配置
|
// 只有在支持工具调用的模型上才添加toolConfig
|
||||||
if (request.tools?.length) {
|
if (request.tools?.length && supportsToolUse(request.modelId)) {
|
||||||
input.toolConfig = {
|
input.toolConfig = {
|
||||||
tools: request.tools.map((tool) => ({
|
tools: request.tools.map((tool) => ({
|
||||||
toolSpec: {
|
toolSpec: {
|
||||||
name: tool.name,
|
name: tool.name,
|
||||||
description: tool.description,
|
description: tool.description,
|
||||||
inputSchema: {
|
inputSchema: {
|
||||||
json: tool.input_schema, // 直接使用对象,不需要 JSON.stringify
|
json: tool.input_schema,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
|
@ -285,7 +285,7 @@ export function showPlugins(provider: ServiceProvider, model: string) {
|
|||||||
if (provider == ServiceProvider.Anthropic && !model.includes("claude-2")) {
|
if (provider == ServiceProvider.Anthropic && !model.includes("claude-2")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (provider == ServiceProvider.Bedrock && !model.includes("claude-2")) {
|
if (provider == ServiceProvider.Bedrock && model.includes("claude-3")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (provider == ServiceProvider.Google && !model.includes("vision")) {
|
if (provider == ServiceProvider.Google && !model.includes("vision")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user