Skip to content

Commit

Permalink
fix: Incorrect template data passed in
Browse files Browse the repository at this point in the history
  • Loading branch information
adolphnov committed Dec 19, 2024
1 parent 072cebc commit 8c918ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tools/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ export function executeTool(toolName: string) {
}

const middleHandler = async (data: any) => {
let result = typeof data !== 'string' ? JSON.stringify(data) : data as any;
let result = data;
const handler = JSON.parse(JSON.stringify(tools[toolName]?.handler || '')) as ToolHandler;
handler && injectPatterns(handler, args);
switch (handler?.type) {
case 'template':
result = processHtmlText(handler.patterns || [], interpolate(handler.data, result));
result = processHtmlText(handler.patterns || [], interpolate(handler.data, data));
break;
case 'webclean':
result = processHtmlText(handler.patterns || [], result);
result = processHtmlText(handler.patterns || [], typeof data !== 'string' ? JSON.stringify(data) : data as any);
break;
}
if (tools[toolName].webcrawler) {
result = await webCrawler(tools[toolName].webcrawler, data);
result = await webCrawler(tools[toolName].webcrawler, result);
}
return result;
};
Expand Down

0 comments on commit 8c918ec

Please sign in to comment.