feat: modules
This commit is contained in:
parent
eb28bfb27b
commit
94a241bbb1
@ -407,13 +407,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
|||||||
type: FlowInputItemTypeEnum.custom,
|
type: FlowInputItemTypeEnum.custom,
|
||||||
label: '目标字段',
|
label: '目标字段',
|
||||||
description: "由 '描述' 和 'key' 组成一个目标字段,可提取多个目标字段",
|
description: "由 '描述' 和 'key' 组成一个目标字段,可提取多个目标字段",
|
||||||
value: [
|
value: []
|
||||||
{
|
|
||||||
key: 'key',
|
|
||||||
desc: '目标字段',
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
outputs: [
|
outputs: [
|
||||||
@ -438,13 +432,6 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
|||||||
valueType: FlowValueTypeEnum.string,
|
valueType: FlowValueTypeEnum.string,
|
||||||
type: FlowOutputItemTypeEnum.source,
|
type: FlowOutputItemTypeEnum.source,
|
||||||
targets: []
|
targets: []
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'key',
|
|
||||||
label: '提取结果-目标字段',
|
|
||||||
valueType: FlowValueTypeEnum.string,
|
|
||||||
type: FlowOutputItemTypeEnum.source,
|
|
||||||
targets: []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@ -34,7 +34,7 @@ const NodeHttp = ({
|
|||||||
key,
|
key,
|
||||||
valueType: FlowValueTypeEnum.string,
|
valueType: FlowValueTypeEnum.string,
|
||||||
type: FlowInputItemTypeEnum.target,
|
type: FlowInputItemTypeEnum.target,
|
||||||
label: 'New Param',
|
label: `入参${inputs.length - 1}`,
|
||||||
edit: true
|
edit: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -59,7 +59,7 @@ const NodeHttp = ({
|
|||||||
value: outputs.concat([
|
value: outputs.concat([
|
||||||
{
|
{
|
||||||
key,
|
key,
|
||||||
label: '出参1',
|
label: `出参${outputs.length}`,
|
||||||
valueType: FlowValueTypeEnum.string,
|
valueType: FlowValueTypeEnum.string,
|
||||||
type: FlowOutputItemTypeEnum.source,
|
type: FlowOutputItemTypeEnum.source,
|
||||||
edit: true,
|
edit: true,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { BaseEdge, EdgeLabelRenderer, EdgeProps, getBezierPath } from 'reactflow
|
|||||||
import { Flex } from '@chakra-ui/react';
|
import { Flex } from '@chakra-ui/react';
|
||||||
import MyIcon from '@/components/Icon';
|
import MyIcon from '@/components/Icon';
|
||||||
|
|
||||||
export default function ButtonEdge({
|
const ButtonEdge = ({
|
||||||
id,
|
id,
|
||||||
sourceX,
|
sourceX,
|
||||||
sourceY,
|
sourceY,
|
||||||
@ -16,7 +16,7 @@ export default function ButtonEdge({
|
|||||||
data
|
data
|
||||||
}: EdgeProps<{
|
}: EdgeProps<{
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
}>) {
|
}>) => {
|
||||||
const [edgePath, labelX, labelY] = getBezierPath({
|
const [edgePath, labelX, labelY] = getBezierPath({
|
||||||
sourceX,
|
sourceX,
|
||||||
sourceY,
|
sourceY,
|
||||||
@ -53,4 +53,6 @@ export default function ButtonEdge({
|
|||||||
</EdgeLabelRenderer>
|
</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>
|
</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({
|
const { mutate: onclickSave, isLoading } = useRequest({
|
||||||
mutationFn: () => {
|
mutationFn: () => {
|
||||||
console.log(flow2AppModules(), '====');
|
|
||||||
return updateAppDetail(app._id, {
|
return updateAppDetail(app._id, {
|
||||||
modules: flow2AppModules()
|
modules: flow2AppModules()
|
||||||
});
|
});
|
||||||
|
|||||||
@ -80,6 +80,11 @@ export const appModule2FlowNode = ({
|
|||||||
(input) => input.label && !template.inputs.find((item) => item.key === input.key)
|
(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
|
// replace item data
|
||||||
const moduleItem: FlowModuleItemType = {
|
const moduleItem: FlowModuleItemType = {
|
||||||
@ -93,7 +98,7 @@ export const appModule2FlowNode = ({
|
|||||||
value: itemInput.value
|
value: itemInput.value
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
outputs: item.outputs.map((output) => {
|
outputs: concatOutputs.map((output) => {
|
||||||
// unChange outputs
|
// unChange outputs
|
||||||
const templateOutput = template.outputs.find((item) => item.key === output.key);
|
const templateOutput = template.outputs.find((item) => item.key === output.key);
|
||||||
|
|
||||||
|
|||||||
@ -328,7 +328,18 @@ const simpleChatTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
|||||||
inputs: chatModelInput(formData),
|
inputs: chatModelInput(formData),
|
||||||
outputs: [
|
outputs: [
|
||||||
{
|
{
|
||||||
key: TaskResponseKeyEnum.answerText,
|
key: 'answerText',
|
||||||
|
label: '模型回复',
|
||||||
|
description: '直接响应,无需配置',
|
||||||
|
type: 'hidden',
|
||||||
|
targets: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'finish',
|
||||||
|
label: '回复结束',
|
||||||
|
description: 'AI 回复完成后触发',
|
||||||
|
valueType: 'boolean',
|
||||||
|
type: 'source',
|
||||||
targets: []
|
targets: []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -518,7 +529,18 @@ const kbTemplate = (formData: EditFormType): AppModuleItemType[] => [
|
|||||||
inputs: chatModelInput(formData),
|
inputs: chatModelInput(formData),
|
||||||
outputs: [
|
outputs: [
|
||||||
{
|
{
|
||||||
key: TaskResponseKeyEnum.answerText,
|
key: 'answerText',
|
||||||
|
label: '模型回复',
|
||||||
|
description: '直接响应,无需配置',
|
||||||
|
type: 'hidden',
|
||||||
|
targets: []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'finish',
|
||||||
|
label: '回复结束',
|
||||||
|
description: 'AI 回复完成后触发',
|
||||||
|
valueType: 'boolean',
|
||||||
|
type: 'source',
|
||||||
targets: []
|
targets: []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user