mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 08:25:07 +00:00
fix: plugin run & setting quote variables (#2150)
* fix * fix * change variables & variablelabels show condition * fix type * fix
This commit is contained in:
@@ -14,7 +14,10 @@ import { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type'
|
||||
import { removeEmptyUserInput } from '@fastgpt/global/core/chat/utils';
|
||||
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
|
||||
import { updatePluginInputByVariables } from '@fastgpt/global/core/workflow/utils';
|
||||
import {
|
||||
filterPluginInputVariables,
|
||||
updatePluginInputByVariables
|
||||
} from '@fastgpt/global/core/workflow/utils';
|
||||
import { NextAPI } from '@/service/middleware/entry';
|
||||
import { GPTMessages2Chats } from '@fastgpt/global/core/chat/adapt';
|
||||
import { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type';
|
||||
@@ -63,6 +66,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
// Plugin need to replace inputs
|
||||
if (isPlugin) {
|
||||
nodes = updatePluginInputByVariables(nodes, variables);
|
||||
variables = filterPluginInputVariables(variables, nodes);
|
||||
} else {
|
||||
if (!userInput) {
|
||||
throw new Error('Params Error');
|
||||
|
@@ -54,7 +54,10 @@ import { NextAPI } from '@/service/middleware/entry';
|
||||
import { getAppLatestVersion } from '@fastgpt/service/core/app/controller';
|
||||
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
|
||||
import { updatePluginInputByVariables } from '@fastgpt/global/core/workflow/utils';
|
||||
import {
|
||||
filterPluginInputVariables,
|
||||
updatePluginInputByVariables
|
||||
} from '@fastgpt/global/core/workflow/utils';
|
||||
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||
import {
|
||||
getPluginInputsFromStoreNodes,
|
||||
@@ -235,6 +238,11 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
)
|
||||
: storeNodes2RuntimeNodes(nodes, getDefaultEntryNodeIds(nodes));
|
||||
|
||||
const runtimeVariables = filterPluginInputVariables(
|
||||
variables,
|
||||
storeNodes2RuntimeNodes(nodes, getDefaultEntryNodeIds(nodes))
|
||||
);
|
||||
|
||||
/* start flow controller */
|
||||
const { flowResponses, flowUsages, assistantResponses, newVariables } = await (async () => {
|
||||
if (app.version === 'v2') {
|
||||
@@ -249,7 +257,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
responseChatItemId,
|
||||
runtimeNodes,
|
||||
runtimeEdges: initWorkflowEdgeStatus(edges),
|
||||
variables,
|
||||
variables: runtimeVariables,
|
||||
query: removeEmptyUserInput(userQuestion.value),
|
||||
histories: newHistories,
|
||||
stream,
|
||||
|
@@ -104,7 +104,7 @@ const EditForm = ({
|
||||
onClose: onCloseToolsSelect
|
||||
} = useDisclosure();
|
||||
|
||||
const formatVariables: any = useMemo(
|
||||
const formatVariables = useMemo(
|
||||
() =>
|
||||
formatEditorVariablePickerIcon([
|
||||
...getSystemVariables(t),
|
||||
@@ -186,6 +186,7 @@ const EditForm = ({
|
||||
}));
|
||||
});
|
||||
}}
|
||||
variableLabels={formatVariables}
|
||||
variables={formatVariables}
|
||||
placeholder={t('common:core.app.tip.chatNodeSystemPromptTip')}
|
||||
title={t('common:core.ai.Prompt')}
|
||||
|
@@ -20,18 +20,16 @@ const TextareaRender = ({ inputs = [], item, nodeId }: RenderInputProps) => {
|
||||
|
||||
// get variable
|
||||
const variables = useCreation(() => {
|
||||
const currentNode = nodeList.find((node) => node.nodeId === nodeId);
|
||||
const nodeVariables = formatEditorVariablePickerIcon(
|
||||
getNodeDynamicInputs(nodeId).map((item) => ({
|
||||
key: item.key,
|
||||
label: item.label,
|
||||
parent: {
|
||||
id: currentNode?.nodeId,
|
||||
label: currentNode?.name,
|
||||
avatar: currentNode?.avatar
|
||||
}
|
||||
}))
|
||||
);
|
||||
const currentNode = nodeList.find((node) => node.nodeId === nodeId)!;
|
||||
const nodeVariables = getNodeDynamicInputs(nodeId).map((item) => ({
|
||||
key: item.key,
|
||||
label: item.label,
|
||||
parent: {
|
||||
id: currentNode.nodeId,
|
||||
label: currentNode.name,
|
||||
avatar: currentNode.avatar
|
||||
}
|
||||
}));
|
||||
|
||||
const sourceNodes = computedNodeInputReference({
|
||||
nodeId,
|
||||
@@ -61,9 +59,7 @@ const TextareaRender = ({ inputs = [], item, nodeId }: RenderInputProps) => {
|
||||
})
|
||||
.flat();
|
||||
|
||||
const formatSourceNodeVariables = formatEditorVariablePickerIcon(sourceNodeVariables);
|
||||
|
||||
return [...nodeVariables, ...formatSourceNodeVariables];
|
||||
return [...nodeVariables, ...sourceNodeVariables];
|
||||
}, [nodeList, edges, inputs, t]);
|
||||
|
||||
const onChange = useCallback(
|
||||
@@ -84,6 +80,7 @@ const TextareaRender = ({ inputs = [], item, nodeId }: RenderInputProps) => {
|
||||
const Render = useMemo(() => {
|
||||
return (
|
||||
<PromptEditor
|
||||
variableLabels={variables}
|
||||
variables={variables}
|
||||
title={t(item.label as any)}
|
||||
maxLength={item.maxLength}
|
||||
|
Reference in New Issue
Block a user