mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
feat: modules
This commit is contained in:
@@ -407,13 +407,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
||||
type: FlowInputItemTypeEnum.custom,
|
||||
label: '目标字段',
|
||||
description: "由 '描述' 和 'key' 组成一个目标字段,可提取多个目标字段",
|
||||
value: [
|
||||
{
|
||||
key: 'key',
|
||||
desc: '目标字段',
|
||||
required: true
|
||||
}
|
||||
]
|
||||
value: []
|
||||
}
|
||||
],
|
||||
outputs: [
|
||||
@@ -438,13 +432,6 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
||||
valueType: FlowValueTypeEnum.string,
|
||||
type: FlowOutputItemTypeEnum.source,
|
||||
targets: []
|
||||
},
|
||||
{
|
||||
key: 'key',
|
||||
label: '提取结果-目标字段',
|
||||
valueType: FlowValueTypeEnum.string,
|
||||
type: FlowOutputItemTypeEnum.source,
|
||||
targets: []
|
||||
}
|
||||
]
|
||||
};
|
||||
|
@@ -34,7 +34,7 @@ const NodeHttp = ({
|
||||
key,
|
||||
valueType: FlowValueTypeEnum.string,
|
||||
type: FlowInputItemTypeEnum.target,
|
||||
label: 'New Param',
|
||||
label: `入参${inputs.length - 1}`,
|
||||
edit: true
|
||||
}
|
||||
});
|
||||
@@ -59,7 +59,7 @@ const NodeHttp = ({
|
||||
value: outputs.concat([
|
||||
{
|
||||
key,
|
||||
label: '出参1',
|
||||
label: `出参${outputs.length}`,
|
||||
valueType: FlowValueTypeEnum.string,
|
||||
type: FlowOutputItemTypeEnum.source,
|
||||
edit: true,
|
||||
|
@@ -3,7 +3,7 @@ import { BaseEdge, EdgeLabelRenderer, EdgeProps, getBezierPath } from 'reactflow
|
||||
import { Flex } from '@chakra-ui/react';
|
||||
import MyIcon from '@/components/Icon';
|
||||
|
||||
export default function ButtonEdge({
|
||||
const ButtonEdge = ({
|
||||
id,
|
||||
sourceX,
|
||||
sourceY,
|
||||
@@ -16,7 +16,7 @@ export default function ButtonEdge({
|
||||
data
|
||||
}: EdgeProps<{
|
||||
onDelete: (id: string) => void;
|
||||
}>) {
|
||||
}>) => {
|
||||
const [edgePath, labelX, labelY] = getBezierPath({
|
||||
sourceX,
|
||||
sourceY,
|
||||
@@ -53,4 +53,6 @@ export default function ButtonEdge({
|
||||
</EdgeLabelRenderer>
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default React.memo(ButtonEdge);
|
||||
|
@@ -10,4 +10,4 @@ const Container = ({ children, ...props }: BoxProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default Container;
|
||||
export default React.memo(Container);
|
||||
|
@@ -19,4 +19,4 @@ const Divider = ({ text }: { text: 'Input' | 'Output' | string }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default Divider;
|
||||
export default React.memo(Divider);
|
||||
|
@@ -27,4 +27,4 @@ const Label = ({
|
||||
</Box>
|
||||
);
|
||||
|
||||
export default Label;
|
||||
export default React.memo(Label);
|
||||
|
@@ -145,4 +145,4 @@ const RenderOutput = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default RenderOutput;
|
||||
export default React.memo(RenderOutput);
|
||||
|
@@ -344,7 +344,6 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
|
||||
|
||||
const { mutate: onclickSave, isLoading } = useRequest({
|
||||
mutationFn: () => {
|
||||
console.log(flow2AppModules(), '====');
|
||||
return updateAppDetail(app._id, {
|
||||
modules: flow2AppModules()
|
||||
});
|
||||
|
@@ -80,6 +80,11 @@ export const appModule2FlowNode = ({
|
||||
(input) => input.label && !template.inputs.find((item) => item.key === input.key)
|
||||
)
|
||||
);
|
||||
const concatOutputs = item.outputs.concat(
|
||||
template.outputs.filter(
|
||||
(templateOutput) => !item.outputs.find((item) => item.key === templateOutput.key)
|
||||
)
|
||||
);
|
||||
|
||||
// replace item data
|
||||
const moduleItem: FlowModuleItemType = {
|
||||
@@ -93,7 +98,7 @@ export const appModule2FlowNode = ({
|
||||
value: itemInput.value
|
||||
};
|
||||
}),
|
||||
outputs: item.outputs.map((output) => {
|
||||
outputs: concatOutputs.map((output) => {
|
||||
// unChange outputs
|
||||
const templateOutput = template.outputs.find((item) => item.key === output.key);
|
||||
|
||||
|
@@ -328,7 +328,18 @@ const simpleChatTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
inputs: chatModelInput(formData),
|
||||
outputs: [
|
||||
{
|
||||
key: TaskResponseKeyEnum.answerText,
|
||||
key: 'answerText',
|
||||
label: '模型回复',
|
||||
description: '直接响应,无需配置',
|
||||
type: 'hidden',
|
||||
targets: []
|
||||
},
|
||||
{
|
||||
key: 'finish',
|
||||
label: '回复结束',
|
||||
description: 'AI 回复完成后触发',
|
||||
valueType: 'boolean',
|
||||
type: 'source',
|
||||
targets: []
|
||||
}
|
||||
],
|
||||
@@ -518,7 +529,18 @@ const kbTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
||||
inputs: chatModelInput(formData),
|
||||
outputs: [
|
||||
{
|
||||
key: TaskResponseKeyEnum.answerText,
|
||||
key: 'answerText',
|
||||
label: '模型回复',
|
||||
description: '直接响应,无需配置',
|
||||
type: 'hidden',
|
||||
targets: []
|
||||
},
|
||||
{
|
||||
key: 'finish',
|
||||
label: '回复结束',
|
||||
description: 'AI 回复完成后触发',
|
||||
valueType: 'boolean',
|
||||
type: 'source',
|
||||
targets: []
|
||||
}
|
||||
],
|
||||
|
Reference in New Issue
Block a user