feat(core): Update LLM applications building support (no-changelog) (#7418)

extracted out of #7336

---------

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: OlegIvaniv <me@olegivaniv.com>
Co-authored-by: Jan Oberhauser <janober@users.noreply.github.com>
Co-authored-by: Val <68596159+valya@users.noreply.github.com>
Co-authored-by: Alex Grozav <alex@grozav.com>
Co-authored-by: Deborah <deborah@starfallprojects.co.uk>
Co-authored-by: Jesper Bylund <mail@jesperbylund.com>
Co-authored-by: Jon <jonathan.bennetts@gmail.com>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-10-20 10:52:56 +02:00
committed by GitHub
parent 34f3f8001e
commit 91dfc4d513
14 changed files with 93 additions and 74 deletions

View File

@@ -133,13 +133,8 @@ import { get, last } from 'lodash-es';
import { useUIStore, useWorkflowsStore } from '@/stores';
import { createEventBus } from 'n8n-design-system/utils';
import {
type INode,
type INodeType,
type ITaskData,
NodeHelpers,
NodeConnectionType,
} from 'n8n-workflow';
import type { IDataObject, INodeType, INode, ITaskData } from 'n8n-workflow';
import { NodeHelpers, NodeConnectionType } from 'n8n-workflow';
import type { INodeUi } from '@/Interface';
const RunDataAi = defineAsyncComponent(async () => import('@/components/RunDataAi/RunDataAi.vue'));
@@ -433,6 +428,17 @@ export default defineComponent({
this.waitForExecution(response.executionId);
},
extractResponseMessage(responseData?: IDataObject) {
if (!responseData) return '<NO RESPONSE FOUND>';
// Paths where the response message might be located
const paths = ['output', 'text', 'response.text'];
const matchedPath = paths.find((path) => get(responseData, path));
if (!matchedPath) return JSON.stringify(responseData, null, 2);
return get(responseData, matchedPath) as string;
},
waitForExecution(executionId?: string) {
const that = this;
const waitInterval = setInterval(() => {
@@ -455,18 +461,7 @@ export default defineComponent({
responseMessage = '[ERROR: ' + get(nodeResponseData, ['error', 'message']) + ']';
} else {
const responseData = get(nodeResponseData, 'data.main[0][0].json');
if (responseData) {
const responseObj = responseData as object & { output?: string };
if (responseObj.output !== undefined) {
responseMessage = responseObj.output;
} else if (Object.keys(responseObj).length === 0) {
responseMessage = '<NO RESPONSE FOUND>';
} else {
responseMessage = JSON.stringify(responseObj, null, 2);
}
} else {
responseMessage = '<NO RESPONSE FOUND>';
}
responseMessage = this.extractResponseMessage(responseData);
}
this.messages.push({