wip commit

This commit is contained in:
Charlie Kolb 2024-11-13 15:29:28 +01:00
parent c33b3a3894
commit 5fb8ef9bec
No known key found for this signature in database
3 changed files with 22 additions and 8 deletions

View file

@ -83,7 +83,7 @@ export const promptTypeOptions: INodeProperties = {
description: 'Use an expression to reference data in previous nodes or enter static text', description: 'Use an expression to reference data in previous nodes or enter static text',
}, },
], ],
default: 'auto', default: 'define',
}; };
export const textInput: INodeProperties = { export const textInput: INodeProperties = {

View file

@ -1116,8 +1116,6 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
return; return;
} }
adjustNewNodes(sourceNode, targetNode, { parentIsNew, childIsNew });
workflowsStore.addConnection({ workflowsStore.addConnection({
connection: mappedConnection, connection: mappedConnection,
}); });
@ -1125,6 +1123,7 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
void nextTick(() => { void nextTick(() => {
nodeHelpers.updateNodeInputIssues(sourceNode); nodeHelpers.updateNodeInputIssues(sourceNode);
nodeHelpers.updateNodeInputIssues(targetNode); nodeHelpers.updateNodeInputIssues(targetNode);
adjustNewNodes(sourceNode, targetNode, { parentIsNew, childIsNew });
}); });
if (!keepPristine) { if (!keepPristine) {

View file

@ -39,10 +39,25 @@ export function adjustNewNodes(
} }
function adjustNewChild(parent: AddedNode, child: AddedNode) { function adjustNewChild(parent: AddedNode, child: AddedNode) {
if (!PROMPT_PROVIDER_NODE_NAMES.includes(parent.type) && AI_NODES.includes(child.type)) { console.log('parent', parent);
Object.assign<AddedNode, Partial<INode>>(child, { console.log('child', child);
parameters: { promptType: 'define' }, if (AI_NODES.includes(child.type)) {
}); const { getCurrentWorkflow } = useWorkflowsStore();
const workflow = getCurrentWorkflow();
const ps = [parent, ...(child.name ? workflow.getParentNodesByDepth(child.name, 1) : [])];
console.log('parents', ps);
if (
ps.some((x) =>
PROMPT_PROVIDER_NODE_NAMES.includes(
'type' in x ? x.type : (workflow.getNode(x?.name ?? '')?.type ?? ''),
),
)
) {
Object.assign<AddedNode, Partial<INode>>(child, {
parameters: { promptType: 'auto' },
});
}
} }
} }
@ -52,7 +67,7 @@ function adjustNewParent(parent: AddedNode, child: AddedNode) {
const workflow = getCurrentWorkflow(); const workflow = getCurrentWorkflow();
// If a memory node is added to an Agent, the memory node is actually the parent since it provides input // If a memory node is added to an Agent, the memory node is actually the parent since it provides input
// So we need to look for the Agent's parents to determine if there is a prompt provider // So we need to look for the Agent's parents to determine if there is a sessionId provider
const ps = workflow.getParentNodesByDepth(child.name, 1); const ps = workflow.getParentNodesByDepth(child.name, 1);
if ( if (
!ps.some((x) => PROMPT_PROVIDER_NODE_NAMES.includes(workflow.getNode(x.name)?.type ?? '')) !ps.some((x) => PROMPT_PROVIDER_NODE_NAMES.includes(workflow.getNode(x.name)?.type ?? ''))