feat: get node variables in prompt editor (#2087)

* feat: get node variables in prompt editor

* fix

* fix build

* merge

* fix build

* delete default parent

* fix

* fix
This commit is contained in:
heheer
2024-07-23 11:20:23 +08:00
committed by GitHub
parent f24e41f5ec
commit a4787bce5c
23 changed files with 897 additions and 61 deletions

View File

@@ -19,6 +19,7 @@ import {
import { replaceVariable } from '@fastgpt/global/common/string/tools';
import { responseWriteNodeStatus } from '../../../common/response';
import { getSystemTime } from '@fastgpt/global/common/time/timezone';
import { replaceVariableLabel } from '@fastgpt/global/core/workflow/utils';
import { dispatchWorkflowStart } from './init/workflowStart';
import { dispatchChatCompletion } from './chat/oneapi';
@@ -54,6 +55,7 @@ import { surrenderProcess } from '../../../common/system/tools';
import { dispatchRunCode } from './code/run';
import { dispatchTextEditor } from './tools/textEditor';
import { dispatchCustomFeedback } from './tools/customFeedback';
import { ReferenceValueProps } from '@fastgpt/global/core/workflow/type/io';
const callbackMap: Record<FlowNodeTypeEnum, Function> = {
[FlowNodeTypeEnum.workflowStart]: dispatchWorkflowStart,
@@ -291,6 +293,14 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
// replace {{}} variables
let value = replaceVariable(input.value, variables);
// replace {{$$}} variables
value = replaceVariableLabel({
text: value,
nodes: runtimeNodes,
variables: variables,
runningNode: node
});
// replace reference variables
value = getReferenceVariableValue({
value,