fix: tool use call

This commit is contained in:
ferenci84 2025-03-09 11:28:53 +01:00
parent 11571e916d
commit c73f72fbb3

View file

@ -172,7 +172,11 @@ class Bedrock extends BaseLLM {
const toolUse = chunk.contentBlockStart.start.toolUse;
if (toolUse?.toolUseId && toolUse?.name) {
// [existing code]
this._currentToolResponse = {
toolUseId: toolUse.toolUseId,
name: toolUse.name,
input: ""
};
}
continue;
}
@ -223,22 +227,20 @@ class Bedrock extends BaseLLM {
const convertedMessages = this._convertMessages(messages);
const supportsTools = PROVIDER_TOOL_SUPPORT.bedrock?.(options.model || "") ?? false;
const tools = (supportsTools && options.tools?.map(tool => ({
toolSpec: {
name: tool.function.name,
description: tool.function.description,
inputSchema: {
json: tool.function.parameters
}
}
}))) || null
return {
modelId: options.model,
messages: convertedMessages,
system: this.systemMessage ? [{ text: this.systemMessage }] : undefined,
toolConfig: tools && tools.length ? {
tools
toolConfig: supportsTools && options.tools ? {
tools: options.tools.map(tool => ({
toolSpec: {
name: tool.function.name,
description: tool.function.description,
inputSchema: {
json: tool.function.parameters
}
}
}))
} : undefined,
inferenceConfig: {
maxTokens: options.maxTokens,