This commit is contained in:
Charlie Kolb 2024-11-12 15:35:58 +01:00
parent 98ec7370b3
commit e56a945b9c
No known key found for this signature in database
4 changed files with 16 additions and 3 deletions

View file

@ -490,6 +490,7 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
}
async function addNodes(nodes: AddedNodesAndConnections['nodes'], options: AddNodesOptions = {}) {
// here?
let insertPosition = options.position;
let lastAddedNode: INodeUi | undefined;
const addedNodes: INodeUi[] = [];

View file

@ -1112,6 +1112,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
nodeData.type = getCredentialOnlyNodeTypeName(nodeData.extendsCredential);
}
// here?
workflow.value.nodes.push(nodeData);
// Init node metadata
if (!nodeMetadata.value[nodeData.name]) {

View file

@ -7,6 +7,8 @@ import {
OPEN_AI_NODE_MESSAGE_ASSISTANT_TYPE,
QA_CHAIN_NODE_TYPE,
} from '@/constants';
import { getParentNodes } from '@/components/ButtonParameter/utils';
import { useWorkflowsStore } from '@/stores/workflows.store';
const AI_NODES = [
QA_CHAIN_NODE_TYPE,
@ -29,14 +31,22 @@ const PROMPT_PROVIDER_NODE_NAMES = [CHAT_TRIGGER_NODE_TYPE];
type NodeWithType = Pick<INode, 'type'>;
export function adjustNewlyConnectedNodes(parent: NodeWithType, child: NodeWithType) {
const { getCurrentWorkflow, getNodeByName } = useWorkflowsStore();
export function adjustNewlyConnectedNodes(parent: INode, child: INode) {
const workflow = getCurrentWorkflow();
if (workflow.getParentNodesByDepth(child.name, 1).length > 0) {
return;
}
if (!PROMPT_PROVIDER_NODE_NAMES.includes(parent.type) && AI_NODES.includes(child.type)) {
Object.assign<NodeWithType, Partial<INode>>(child, {
Object.assign<INode, Partial<INode>>(child, {
parameters: { promptType: 'define' },
});
}
if (!PROMPT_PROVIDER_NODE_NAMES.includes(parent.type) && MEMORY_NODE_NAMES.includes(child.type)) {
Object.assign<NodeWithType, Partial<INode>>(child, {
Object.assign<INode, Partial<INode>>(child, {
parameters: { sessionIdType: 'customKey' },
});
}

View file

@ -867,6 +867,7 @@ async function onAddNodesAndConnections(
return;
}
// before here?
const addedNodes = await addNodes(nodes, {
dragAndDrop,
position,