|
|
|
@@ -26,7 +26,7 @@ export class Anthropic extends LLMProvider {
|
|
|
|
h[c.is_error ? 'error' : 'content'] = c.content;
|
|
|
|
h[c.is_error ? 'error' : 'content'] = c.content;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
history[orgI].content = history[orgI].content.filter((c: any) => c.type == 'text').map((c: any) => c.text).join('\n\n');
|
|
|
|
history[orgI].content = history[orgI].content?.filter((c: any) => c.type == 'text').map((c: any) => c.text).join('\n\n');
|
|
|
|
if(!history[orgI].content) history.splice(orgI, 1);
|
|
|
|
if(!history[orgI].content) history.splice(orgI, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!history[orgI].timestamp) history[orgI].timestamp = Date.now();
|
|
|
|
if(!history[orgI].timestamp) history[orgI].timestamp = Date.now();
|
|
|
|
@@ -119,7 +119,6 @@ export class Anthropic extends LLMProvider {
|
|
|
|
if(options.stream) options.stream({tool: toolCall.name});
|
|
|
|
if(options.stream) options.stream({tool: toolCall.name});
|
|
|
|
if(!tool) return {tool_use_id: toolCall.id, is_error: true, content: 'Tool not found'};
|
|
|
|
if(!tool) return {tool_use_id: toolCall.id, is_error: true, content: 'Tool not found'};
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
console.log(typeof tool.fn);
|
|
|
|
|
|
|
|
const result = await tool.fn(toolCall.input, options?.stream, this.ai);
|
|
|
|
const result = await tool.fn(toolCall.input, options?.stream, this.ai);
|
|
|
|
return {type: 'tool_result', tool_use_id: toolCall.id, content: JSONSanitize(result)};
|
|
|
|
return {type: 'tool_result', tool_use_id: toolCall.id, content: JSONSanitize(result)};
|
|
|
|
} catch (err: any) {
|
|
|
|
} catch (err: any) {
|
|
|
|
|