mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix(AI Agent Node): Improve Tools agent empty tool input message (#9622)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
parent
a8bb53f4e3
commit
e7f616290f
|
@ -190,7 +190,14 @@ const agentTypeProperty: INodeProperties = {
|
|||
name: 'agent',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Tools Agent',
|
||||
value: 'toolsAgent',
|
||||
description:
|
||||
'Utilized unified Tool calling interface to select the appropriate tools and argument for execution',
|
||||
},
|
||||
{
|
||||
name: 'Conversational Agent',
|
||||
value: 'conversationalAgent',
|
||||
|
@ -219,12 +226,6 @@ const agentTypeProperty: INodeProperties = {
|
|||
value: 'sqlAgent',
|
||||
description: 'Answers questions about data in an SQL database',
|
||||
},
|
||||
{
|
||||
name: 'Tools Agent',
|
||||
value: 'toolsAgent',
|
||||
description:
|
||||
'Utilized unified Tool calling interface to select the appropriate tools and argument for execution',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
};
|
||||
|
|
|
@ -155,11 +155,19 @@ export async function toolsAgentExecute(this: IExecuteFunctions): Promise<INodeE
|
|||
throw new NodeOperationError(this.getNode(), 'The ‘text parameter is empty.');
|
||||
}
|
||||
|
||||
// OpenAI doesn't allow empty tools array so we will provide a more user-friendly error message
|
||||
if (model.lc_namespace.includes('openai') && tools.length === 0) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
"Please connect at least one tool. If you don't need any, try the conversational agent instead",
|
||||
);
|
||||
}
|
||||
|
||||
const response = await executor.invoke({
|
||||
input,
|
||||
system_message: options.systemMessage ?? SYSTEM_MESSAGE,
|
||||
formatting_instructions:
|
||||
'IMPORTANT: Always call `format_final_response` to format your final response!', //outputParser?.getFormatInstructions(),
|
||||
'IMPORTANT: Always call `format_final_response` to format your final response!',
|
||||
});
|
||||
|
||||
returnData.push({
|
||||
|
@ -174,7 +182,10 @@ export async function toolsAgentExecute(this: IExecuteFunctions): Promise<INodeE
|
|||
});
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ json: { error: error.message }, pairedItem: { item: itemIndex } });
|
||||
returnData.push({
|
||||
json: { error: error?.message },
|
||||
pairedItem: { item: itemIndex },
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue