Fix 4.8 node (#1370)

* perf: runtime props

* fix: Plugin run faied in debug mode

* perf: variable update

* fix: ts

* perf: variable ui
This commit is contained in:
Archer
2024-05-06 17:13:50 +08:00
committed by GitHub
parent 5bb9c550f6
commit eef609a063
37 changed files with 398 additions and 249 deletions

View File

@@ -5,7 +5,11 @@ import { SseResponseEventEnum } from '@fastgpt/global/core/workflow/runtime/cons
import { responseWrite } from '@fastgpt/service/common/response';
import { pushChatUsage } from '@/service/support/wallet/usage/push';
import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants';
import type { ChatItemType, ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
import type {
ChatItemType,
ChatItemValueItemType,
UserChatItemValueItemType
} from '@fastgpt/global/core/chat/type';
import { authApp } from '@fastgpt/service/support/permission/auth/app';
import { dispatchWorkFlow } from '@fastgpt/service/core/workflow/dispatch';
import { authCert } from '@fastgpt/service/support/permission/auth/common';
@@ -13,10 +17,11 @@ import { getUserChatInfoAndAuthTeamPoints } from '@/service/support/permission/a
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';
import { RuntimeEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
import { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type';
import { removeEmptyUserInput } from '@fastgpt/global/core/chat/utils';
export type Props = {
history: ChatItemType[];
prompt: ChatItemValueItemType[];
prompt: UserChatItemValueItemType[];
nodes: RuntimeNodeItemType[];
edges: RuntimeEdgeItemType[];
variables: Record<string, any>;
@@ -33,7 +38,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
res.end();
});
const {
let {
nodes = [],
edges = [],
history = [],
@@ -66,8 +71,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// auth balance
const { user } = await getUserChatInfoAndAuthTeamPoints(tmbId);
const { text, files } = chatValue2RuntimePrompt(prompt);
/* start process */
const { flowResponses, flowUsages, newVariables } = await dispatchWorkFlow({
res,
@@ -78,11 +81,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
appId,
runtimeNodes: nodes,
runtimeEdges: edges,
variables: {
...variables,
userChatInput: text
},
inputFiles: files,
variables,
query: removeEmptyUserInput(prompt),
histories: history,
stream: true,
detail: true,

View File

@@ -57,7 +57,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...variables,
userChatInput: ''
},
inputFiles: [],
query: [],
histories: [],
stream: false,
detail: true,

View File

@@ -24,7 +24,10 @@ import { pushResult2Remote, addOutLinkUsage } from '@fastgpt/service/support/out
import requestIp from 'request-ip';
import { getUsageSourceByAuthType } from '@fastgpt/global/support/wallet/usage/tools';
import { authTeamSpaceToken } from '@/service/support/permission/auth/team';
import { filterPublicNodeResponseData } from '@fastgpt/global/core/chat/utils';
import {
filterPublicNodeResponseData,
removeEmptyUserInput
} from '@fastgpt/global/core/chat/utils';
import { updateApiKeyUsage } from '@fastgpt/service/support/openapi/tools';
import { connectToDatabase } from '@/service/mongo';
import { getUserChatInfoAndAuthTeamPoints } from '@/service/support/permission/auth/team';
@@ -192,11 +195,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
responseChatItemId,
runtimeNodes: storeNodes2RuntimeNodes(nodes, getDefaultEntryNodeIds(nodes)),
runtimeEdges: initWorkflowEdgeStatus(edges),
variables: {
...variables,
userChatInput: text
},
inputFiles: files,
variables,
query: removeEmptyUserInput(question.value),
histories: concatHistories,
stream,
detail,

View File

@@ -31,7 +31,7 @@ export const defaultForm: EditFormType = {
modules: [
{
nodeId: nanoid(),
name: '定义插件输入',
name: '定义插件输入',
avatar: '/imgs/workflow/input.png',
flowNodeType: 'pluginInput',
showStatus: false,
@@ -44,7 +44,7 @@ export const defaultForm: EditFormType = {
},
{
nodeId: nanoid(),
name: '定义插件输出',
name: '定义插件输出',
avatar: '/imgs/workflow/output.png',
flowNodeType: 'pluginOutput',
showStatus: false,