mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
18 lines
538 B
TypeScript
18 lines
538 B
TypeScript
import type { Tool } from '@langchain/core/tools';
|
|
import { type IDataObject, type INodeExecutionData } from 'n8n-workflow';
|
|
|
|
import { convertObjectBySchema } from './convertToSchema';
|
|
|
|
export async function executeTool(tool: Tool, query: string | object): Promise<INodeExecutionData> {
|
|
let convertedQuery: string | object = query;
|
|
if ('schema' in tool && tool.schema) {
|
|
convertedQuery = convertObjectBySchema(query, tool.schema);
|
|
}
|
|
|
|
const result = await tool.invoke(convertedQuery);
|
|
|
|
return {
|
|
json: result as IDataObject,
|
|
};
|
|
}
|