Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
94a241bb
authored
Aug 04, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: modules
parent
eb28bfb2
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
42 additions
and
27 deletions
+42
-27
client/src/constants/flow/ModuleTemplate.ts
+1
-14
client/src/pages/app/detail/components/AdEdit/components/Nodes/NodeHttp.tsx
+2
-2
client/src/pages/app/detail/components/AdEdit/components/modules/ButtonEdge.tsx
+5
-3
client/src/pages/app/detail/components/AdEdit/components/modules/Container.tsx
+1
-1
client/src/pages/app/detail/components/AdEdit/components/modules/Divider.tsx
+1
-1
client/src/pages/app/detail/components/AdEdit/components/modules/Label.tsx
+1
-1
client/src/pages/app/detail/components/AdEdit/components/render/RenderOutput.tsx
+1
-1
client/src/pages/app/detail/components/AdEdit/index.tsx
+0
-1
client/src/utils/adapt.ts
+6
-1
client/src/utils/app.ts
+24
-2
No files found.
client/src/constants/flow/ModuleTemplate.ts
View file @
94a241bb
...
@@ -407,13 +407,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
...
@@ -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 = {
...
@@ -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: []
}
}
]
]
};
};
...
...
client/src/pages/app/detail/components/AdEdit/components/Nodes/NodeHttp.tsx
View file @
94a241bb
...
@@ -34,7 +34,7 @@ const NodeHttp = ({
...
@@ -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 = ({
...
@@ -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
,
...
...
client/src/pages/app/detail/components/AdEdit/components/modules/ButtonEdge.tsx
View file @
94a241bb
...
@@ -3,7 +3,7 @@ import { BaseEdge, EdgeLabelRenderer, EdgeProps, getBezierPath } from 'reactflow
...
@@ -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({
...
@@ -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({
...
@@ -53,4 +53,6 @@ export default function ButtonEdge({
</
EdgeLabelRenderer
>
</
EdgeLabelRenderer
>
</>
</>
);
);
}
};
export
default
React
.
memo
(
ButtonEdge
);
client/src/pages/app/detail/components/AdEdit/components/modules/Container.tsx
View file @
94a241bb
...
@@ -10,4 +10,4 @@ const Container = ({ children, ...props }: BoxProps) => {
...
@@ -10,4 +10,4 @@ const Container = ({ children, ...props }: BoxProps) => {
);
);
};
};
export
default
Container
;
export
default
React
.
memo
(
Container
)
;
client/src/pages/app/detail/components/AdEdit/components/modules/Divider.tsx
View file @
94a241bb
...
@@ -19,4 +19,4 @@ const Divider = ({ text }: { text: 'Input' | 'Output' | string }) => {
...
@@ -19,4 +19,4 @@ const Divider = ({ text }: { text: 'Input' | 'Output' | string }) => {
);
);
};
};
export
default
Divider
;
export
default
React
.
memo
(
Divider
)
;
client/src/pages/app/detail/components/AdEdit/components/modules/Label.tsx
View file @
94a241bb
...
@@ -27,4 +27,4 @@ const Label = ({
...
@@ -27,4 +27,4 @@ const Label = ({
</
Box
>
</
Box
>
);
);
export
default
Label
;
export
default
React
.
memo
(
Label
)
;
client/src/pages/app/detail/components/AdEdit/components/render/RenderOutput.tsx
View file @
94a241bb
...
@@ -145,4 +145,4 @@ const RenderOutput = ({
...
@@ -145,4 +145,4 @@ const RenderOutput = ({
);
);
};
};
export
default
Re
nderOutput
;
export
default
Re
act
.
memo
(
RenderOutput
)
;
client/src/pages/app/detail/components/AdEdit/index.tsx
View file @
94a241bb
...
@@ -344,7 +344,6 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
...
@@ -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
()
});
});
...
...
client/src/utils/adapt.ts
View file @
94a241bb
...
@@ -80,6 +80,11 @@ export const appModule2FlowNode = ({
...
@@ -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 = ({
...
@@ -93,7 +98,7 @@ export const appModule2FlowNode = ({
value
:
itemInput
.
value
value
:
itemInput
.
value
};
};
}),
}),
outputs
:
item
.
o
utputs
.
map
((
output
)
=>
{
outputs
:
concatO
utputs
.
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
);
...
...
client/src/utils/app.ts
View file @
94a241bb
...
@@ -328,7 +328,18 @@ const simpleChatTemplate = (formData: EditFormType): AppModuleItemType[] => [
...
@@ -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[] => [
...
@@ -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
:
[]
}
}
],
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment