diff --git a/cypress/composables/ndv.ts b/cypress/composables/ndv.ts index b7ea33cb69..903637d3ba 100644 --- a/cypress/composables/ndv.ts +++ b/cypress/composables/ndv.ts @@ -52,6 +52,10 @@ export function getOutputPanelTable() { return getOutputPanelDataContainer().get('table'); } +export function getNoToolsUsedCallout() { + return cy.getByTestId('no-tools-used-callout'); +} + /** * Actions */ diff --git a/cypress/e2e/30-langchain.cy.ts b/cypress/e2e/30-langchain.cy.ts index fb453816f6..a2212338f6 100644 --- a/cypress/e2e/30-langchain.cy.ts +++ b/cypress/e2e/30-langchain.cy.ts @@ -27,6 +27,8 @@ import { clickCreateNewCredential, clickExecuteNode, clickGetBackToCanvas, + getNoToolsUsedCallout, + getOutputPanelTable, toggleParameterCheckboxInputByName, } from '../composables/ndv'; import { @@ -411,4 +413,101 @@ describe('Langchain Integration', () => { assertInputOutputText('Berlin', 'not.exist'); assertInputOutputText('Kyiv', 'not.exist'); }); + + it.only('should show tool info notice if no existing tools were used during execution', () => { + addNodeToCanvas(MANUAL_CHAT_TRIGGER_NODE_NAME, true); + addNodeToCanvas(AGENT_NODE_NAME, true); + + addLanguageModelNodeToParent( + AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME, + AGENT_NODE_NAME, + true, + ); + + clickCreateNewCredential(); + setCredentialValues({ + apiKey: 'sk_test_123', + }); + clickGetBackToCanvas(); + + addToolNodeToParent(AI_TOOL_CALCULATOR_NODE_NAME, AGENT_NODE_NAME); + clickGetBackToCanvas(); + openNode(AGENT_NODE_NAME); + + const inputMessage = 'Hello!'; + const outputMessage = 'Hi there! How can I assist you today?'; + + clickExecuteNode(); + + runMockWorkflowExecution({ + trigger: () => sendManualChatMessage(inputMessage), + runData: [ + createMockNodeExecutionData(AGENT_NODE_NAME, { + jsonData: { + main: { output: outputMessage }, + }, + metadata: { + subRun: [{ node: AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME, runIndex: 0 }], + }, + }), + ], + lastNodeExecuted: AGENT_NODE_NAME, + }); + closeManualChatModal(); + openNode(AGENT_NODE_NAME); + + getNoToolsUsedCallout().should('exist'); + }); + + it('should not show tool info notice if tools were used during execution', () => { + addNodeToCanvas(MANUAL_CHAT_TRIGGER_NODE_NAME, true); + addNodeToCanvas(AGENT_NODE_NAME, true); + + addLanguageModelNodeToParent( + AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME, + AGENT_NODE_NAME, + true, + ); + + clickCreateNewCredential(); + setCredentialValues({ + apiKey: 'sk_test_123', + }); + clickGetBackToCanvas(); + + addToolNodeToParent(AI_TOOL_CALCULATOR_NODE_NAME, AGENT_NODE_NAME); + clickGetBackToCanvas(); + openNode(AGENT_NODE_NAME); + + const inputMessage = 'Hello!'; + const outputMessage = 'Hi there! How can I assist you today?'; + + clickExecuteNode(); + + runMockWorkflowExecution({ + trigger: () => sendManualChatMessage(inputMessage), + runData: [ + createMockNodeExecutionData(AGENT_NODE_NAME, { + jsonData: { + main: { output: outputMessage }, + }, + metadata: { + subRun: [ + { node: AI_LANGUAGE_MODEL_OPENAI_CHAT_MODEL_NODE_NAME, runIndex: 0 }, + { node: AI_TOOL_CALCULATOR_NODE_NAME, runIndex: 0 }, + ], + }, + }), + createMockNodeExecutionData(AI_TOOL_CALCULATOR_NODE_NAME, {}), + ], + lastNodeExecuted: AGENT_NODE_NAME, + }); + + closeManualChatModal(); + openNode(AGENT_NODE_NAME); + // This waits to ensure the output panel is rendered + getOutputPanelTable(); + + getNoToolsUsedCallout().should('not.exist'); + }); }); diff --git a/packages/editor-ui/src/components/OutputPanel.vue b/packages/editor-ui/src/components/OutputPanel.vue index 558eb0d919..6ccfbdaa71 100644 --- a/packages/editor-ui/src/components/OutputPanel.vue +++ b/packages/editor-ui/src/components/OutputPanel.vue @@ -388,7 +388,7 @@ const shouldShowWarning = computed(() => {