diff --git a/packages/service/core/workflow/dispatch/plugin/run.ts b/packages/service/core/workflow/dispatch/plugin/run.ts index 40182ce08..0c0ec88a5 100644 --- a/packages/service/core/workflow/dispatch/plugin/run.ts +++ b/packages/service/core/workflow/dispatch/plugin/run.ts @@ -14,6 +14,7 @@ import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant'; import { computedPluginUsage } from '../../../app/plugin/utils'; import { filterSystemVariables } from '../utils'; import { getPluginRunUserQuery } from '../../utils'; +import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt'; type RunPluginProps = ModuleDispatchProps<{ [key: string]: any; @@ -25,6 +26,7 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise -): UserChatItemType & { dataId: string } => { +export const getPluginRunUserQuery = ({ + nodes, + variables, + files = [] +}: { + nodes: StoreNodeItemType[]; + variables: Record; + files?: RuntimeUserPromptType['files']; +}): UserChatItemType & { dataId: string } => { return { dataId: getNanoid(24), obj: ChatRoleEnum.Human, - value: [ - { - type: ChatItemValueTypeEnum.text, - text: { - content: getPluginRunContent({ - pluginInputs: getPluginInputsFromStoreNodes(nodes), - variables - }) - } - } - ] + value: runtimePrompt2ChatsValue({ + text: getPluginRunContent({ + pluginInputs: getPluginInputsFromStoreNodes(nodes), + variables + }), + files + }) }; }; diff --git a/projects/app/src/pages/api/v1/chat/completions.ts b/projects/app/src/pages/api/v1/chat/completions.ts index 90b99e02b..80fd0de7a 100644 --- a/projects/app/src/pages/api/v1/chat/completions.ts +++ b/projects/app/src/pages/api/v1/chat/completions.ts @@ -189,7 +189,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { // Get obj=Human history const userQuestion: UserChatItemType = (() => { if (isPlugin) { - return getPluginRunUserQuery(app.modules, variables); + // TODO:get plugin files from variables + return getPluginRunUserQuery({ nodes: app.modules, variables }); } const latestHumanChat = chatMessages.pop() as UserChatItemType | undefined;