mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat(Think Tool Node): ToolThink, a simple tool to force the AI agent to do some thinking (#14351)
This commit is contained in:
committed by
GitHub
parent
85cbfb64c0
commit
281b70be04
@@ -0,0 +1,34 @@
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { DynamicTool } from 'langchain/tools';
|
||||
import type { ISupplyDataFunctions } from 'n8n-workflow';
|
||||
|
||||
import { ToolThink } from '../ToolThink.node';
|
||||
|
||||
describe('ToolThink', () => {
|
||||
const thinkTool = new ToolThink();
|
||||
const helpers = mock<ISupplyDataFunctions['helpers']>();
|
||||
const executeFunctions = mock<ISupplyDataFunctions>({
|
||||
helpers,
|
||||
});
|
||||
executeFunctions.addInputData.mockReturnValue({ index: 0 });
|
||||
executeFunctions.getNodeParameter.mockImplementation((paramName: string) => {
|
||||
switch (paramName) {
|
||||
case 'description':
|
||||
return 'Tool description';
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
describe('Tool response', () => {
|
||||
it('should return the same text as response when receiving a text input', async () => {
|
||||
const { response } = (await thinkTool.supplyData.call(executeFunctions, 0)) as {
|
||||
response: DynamicTool;
|
||||
};
|
||||
expect(response).toBeInstanceOf(DynamicTool);
|
||||
expect(response.description).toEqual('Tool description');
|
||||
const res = (await response.invoke('foo')) as string;
|
||||
expect(res).toEqual('foo');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user