Plugin support select file (#2756)

* feat: plugin support upload files (#2716)

* feat: plugin support file upload

* file history

* fix history & chattest

* chore: code

* plugin config icon & file preview padding

* perf: undefined fn

* fix: plugin file numbers & plugin template add config (#2743)

* perf: run plugin without human message (#2749)

* perf: run plugin without human message

* fix build

* fix build

* rename node

* perf: ui

* perf: plugin rerun with last params & plugin log add file (#2755)

* perf: plugin run with last params & plugin log add file

* delete console

* perf: plugin refresh code

* fix: ts

---------

Co-authored-by: heheer <heheer@sealos.io>
This commit is contained in:
Archer
2024-09-20 14:12:58 +08:00
committed by GitHub
parent 5e7c97b7b8
commit 75af549c7f
59 changed files with 2032 additions and 854 deletions

View File

@@ -13,8 +13,9 @@ import { authPluginByTmbId } from '../../../../support/permission/app/auth';
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';
import { getPluginRunUserQuery } from '@fastgpt/global/core/workflow/utils';
import { getPluginInputsFromStoreNodes } from '@fastgpt/global/core/app/plugin/utils';
type RunPluginProps = ModuleDispatchProps<{
[key: string]: any;
@@ -79,7 +80,7 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
},
variables: runtimeVariables,
query: getPluginRunUserQuery({
nodes: plugin.nodes,
pluginInputs: getPluginInputsFromStoreNodes(plugin.nodes),
variables: runtimeVariables,
files
}).value,

View File

@@ -1,3 +1,6 @@
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';
import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type';
export type PluginInputProps = ModuleDispatchProps<{
@@ -5,7 +8,16 @@ export type PluginInputProps = ModuleDispatchProps<{
}>;
export const dispatchPluginInput = (props: PluginInputProps) => {
const { params } = props;
const { params, query } = props;
const { files } = chatValue2RuntimePrompt(query);
return params;
return {
...params,
[DispatchNodeResponseKeyEnum.nodeResponse]: {},
[NodeOutputKeyEnum.userFiles]: files
.map((item) => {
return item?.url ?? '';
})
.filter(Boolean)
};
};

View File

@@ -32,26 +32,3 @@ export const filterSearchResultsByMaxChars = async (
return results.length === 0 ? list.slice(0, 1) : results;
};
/* Get plugin runtime input user query */
export const getPluginRunUserQuery = ({
nodes,
variables,
files = []
}: {
nodes: StoreNodeItemType[];
variables: Record<string, any>;
files?: RuntimeUserPromptType['files'];
}): UserChatItemType & { dataId: string } => {
return {
dataId: getNanoid(24),
obj: ChatRoleEnum.Human,
value: runtimePrompt2ChatsValue({
text: getPluginRunContent({
pluginInputs: getPluginInputsFromStoreNodes(nodes),
variables
}),
files
})
};
};