mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-24 06:30:16 +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(
|
||||
request: ConverseRequest,
|
||||
): ConverseStreamCommandInput {
|
||||
@ -96,15 +104,15 @@ function formatRequestBody(
|
||||
}),
|
||||
};
|
||||
|
||||
// 添加工具配置
|
||||
if (request.tools?.length) {
|
||||
// 只有在支持工具调用的模型上才添加toolConfig
|
||||
if (request.tools?.length && supportsToolUse(request.modelId)) {
|
||||
input.toolConfig = {
|
||||
tools: request.tools.map((tool) => ({
|
||||
toolSpec: {
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
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")) {
|
||||
return true;
|
||||
}
|
||||
if (provider == ServiceProvider.Bedrock && !model.includes("claude-2")) {
|
||||
if (provider == ServiceProvider.Bedrock && model.includes("claude-3")) {
|
||||
return true;
|
||||
}
|
||||
if (provider == ServiceProvider.Google && !model.includes("vision")) {
|
||||
|
Loading…
Reference in New Issue
Block a user