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
118e3336
authored
Jul 27, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: flow value type
parent
97c7984d
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
292 additions
and
79 deletions
+292
-79
client/src/constants/flow/ModuleTemplate.ts
+25
-5
client/src/constants/flow/index.ts
+32
-0
client/src/constants/flow/inputTemplate.ts
+7
-4
client/src/pages/api/admin/initv4.ts
+0
-1
client/src/pages/app/detail/components/AdEdit/components/Nodes/NodeCQNode.tsx
+3
-14
client/src/pages/app/detail/components/AdEdit/components/Nodes/NodeQuestionInput.tsx
+11
-16
client/src/pages/app/detail/components/AdEdit/components/modules/NodeCard.tsx
+5
-1
client/src/pages/app/detail/components/AdEdit/components/render/RenderInput.tsx
+6
-18
client/src/pages/app/detail/components/AdEdit/components/render/RenderOutput.tsx
+3
-14
client/src/pages/app/detail/components/AdEdit/components/render/SourceHandle.tsx
+42
-0
client/src/pages/app/detail/components/AdEdit/components/render/TargetHandle.tsx
+44
-0
client/src/service/moduleDispatch/chat/oneapi.ts
+3
-1
client/src/types/flow.d.ts
+4
-1
client/src/utils/adapt.ts
+1
-4
docSite/docs/datasets/prompt.md
+106
-0
No files found.
client/src/constants/flow/ModuleTemplate.ts
View file @
118e3336
...
@@ -4,7 +4,8 @@ import {
...
@@ -4,7 +4,8 @@ import {
FlowModuleTypeEnum
,
FlowModuleTypeEnum
,
FlowInputItemTypeEnum
,
FlowInputItemTypeEnum
,
FlowOutputItemTypeEnum
,
FlowOutputItemTypeEnum
,
SpecialInputKeyEnum
SpecialInputKeyEnum
,
FlowValueTypeEnum
}
from
'./index'
;
}
from
'./index'
;
import
type
{
AppItemType
}
from
'@/types/app'
;
import
type
{
AppItemType
}
from
'@/types/app'
;
import
type
{
FlowModuleTemplateType
}
from
'@/types/flow'
;
import
type
{
FlowModuleTemplateType
}
from
'@/types/flow'
;
...
@@ -56,7 +57,7 @@ export const UserGuideModule: FlowModuleTemplateType = {
...
@@ -56,7 +57,7 @@ export const UserGuideModule: FlowModuleTemplateType = {
};
};
export
const
UserInputModule
:
FlowModuleTemplateType
=
{
export
const
UserInputModule
:
FlowModuleTemplateType
=
{
logo
:
'/imgs/module/userChatInput.png'
,
logo
:
'/imgs/module/userChatInput.png'
,
name
:
'用户问题'
,
name
:
'用户问题
(对话入口)
'
,
intro
:
'用户输入的内容。该模块通常作为应用的入口,用户在发送消息后会首先执行该模块。'
,
intro
:
'用户输入的内容。该模块通常作为应用的入口,用户在发送消息后会首先执行该模块。'
,
flowType
:
FlowModuleTypeEnum
.
questionInput
,
flowType
:
FlowModuleTypeEnum
.
questionInput
,
url
:
'/app/modules/init/userChatInput'
,
url
:
'/app/modules/init/userChatInput'
,
...
@@ -72,6 +73,7 @@ export const UserInputModule: FlowModuleTemplateType = {
...
@@ -72,6 +73,7 @@ export const UserInputModule: FlowModuleTemplateType = {
key
:
SystemInputEnum
.
userChatInput
,
key
:
SystemInputEnum
.
userChatInput
,
label
:
'用户问题'
,
label
:
'用户问题'
,
type
:
FlowOutputItemTypeEnum
.
source
,
type
:
FlowOutputItemTypeEnum
.
source
,
valueType
:
FlowValueTypeEnum
.
string
,
targets
:
[]
targets
:
[]
}
}
]
]
...
@@ -101,6 +103,7 @@ export const HistoryModule: FlowModuleTemplateType = {
...
@@ -101,6 +103,7 @@ export const HistoryModule: FlowModuleTemplateType = {
{
{
key
:
SystemInputEnum
.
history
,
key
:
SystemInputEnum
.
history
,
label
:
'聊天记录'
,
label
:
'聊天记录'
,
valueType
:
FlowValueTypeEnum
.
chatHistory
,
type
:
FlowOutputItemTypeEnum
.
source
,
type
:
FlowOutputItemTypeEnum
.
source
,
targets
:
[]
targets
:
[]
}
}
...
@@ -155,6 +158,7 @@ export const ChatModule: FlowModuleTemplateType = {
...
@@ -155,6 +158,7 @@ export const ChatModule: FlowModuleTemplateType = {
key: 'systemPrompt',
key: 'systemPrompt',
type: FlowInputItemTypeEnum.textarea,
type: FlowInputItemTypeEnum.textarea,
label: '系统提示词',
label: '系统提示词',
valueType: FlowValueTypeEnum.string,
description: ChatModelSystemTip,
description: ChatModelSystemTip,
placeholder: ChatModelSystemTip,
placeholder: ChatModelSystemTip,
value: ''
value: ''
...
@@ -162,6 +166,7 @@ export const ChatModule: FlowModuleTemplateType = {
...
@@ -162,6 +166,7 @@ export const ChatModule: FlowModuleTemplateType = {
{
{
key: 'limitPrompt',
key: 'limitPrompt',
type: FlowInputItemTypeEnum.textarea,
type: FlowInputItemTypeEnum.textarea,
valueType: FlowValueTypeEnum.string,
label: '限定词',
label: '限定词',
description: ChatModelLimitTip,
description: ChatModelLimitTip,
placeholder: ChatModelLimitTip,
placeholder: ChatModelLimitTip,
...
@@ -171,7 +176,8 @@ export const ChatModule: FlowModuleTemplateType = {
...
@@ -171,7 +176,8 @@ export const ChatModule: FlowModuleTemplateType = {
{
{
key: 'quoteQA',
key: 'quoteQA',
type: FlowInputItemTypeEnum.target,
type: FlowInputItemTypeEnum.target,
label: '引用内容'
label: '引用内容',
valueType: FlowValueTypeEnum.kbQuote
},
},
Input_Template_History,
Input_Template_History,
Input_Template_UserChatInput
Input_Template_UserChatInput
...
@@ -183,6 +189,14 @@ export const ChatModule: FlowModuleTemplateType = {
...
@@ -183,6 +189,14 @@ export const ChatModule: FlowModuleTemplateType = {
description: '直接响应,无需配置',
description: '直接响应,无需配置',
type: FlowOutputItemTypeEnum.hidden,
type: FlowOutputItemTypeEnum.hidden,
targets: []
targets: []
},
{
key: 'finish',
label: '回复结束',
description: 'AI 回复完成后触发',
valueType: FlowValueTypeEnum.boolean,
type: FlowOutputItemTypeEnum.source,
targets: []
}
}
]
]
};
};
...
@@ -236,12 +250,14 @@ export const KBSearchModule: FlowModuleTemplateType = {
...
@@ -236,12 +250,14 @@ export const KBSearchModule: FlowModuleTemplateType = {
key: 'isEmpty',
key: 'isEmpty',
label: '搜索结果为空',
label: '搜索结果为空',
type: FlowOutputItemTypeEnum.source,
type: FlowOutputItemTypeEnum.source,
valueType: FlowValueTypeEnum.boolean,
targets: []
targets: []
},
},
{
{
key: 'unEmpty',
key: 'unEmpty',
label: '搜索结果不为空',
label: '搜索结果不为空',
type: FlowOutputItemTypeEnum.source,
type: FlowOutputItemTypeEnum.source,
valueType: FlowValueTypeEnum.boolean,
targets: []
targets: []
},
},
{
{
...
@@ -249,6 +265,7 @@ export const KBSearchModule: FlowModuleTemplateType = {
...
@@ -249,6 +265,7 @@ export const KBSearchModule: FlowModuleTemplateType = {
label: '引用内容',
label: '引用内容',
description: '搜索结果为空时不返回',
description: '搜索结果为空时不返回',
type: FlowOutputItemTypeEnum.source,
type: FlowOutputItemTypeEnum.source,
valueType: FlowValueTypeEnum.kbQuote,
targets: []
targets: []
}
}
]
]
...
@@ -257,7 +274,8 @@ export const KBSearchModule: FlowModuleTemplateType = {
...
@@ -257,7 +274,8 @@ export const KBSearchModule: FlowModuleTemplateType = {
export const AnswerModule: FlowModuleTemplateType = {
export const AnswerModule: FlowModuleTemplateType = {
logo: '/imgs/module/reply.png',
logo: '/imgs/module/reply.png',
name: '指定回复',
name: '指定回复',
intro: '该模块可以直接回复一段指定的内容。常用于引导、提示。',
intro: '该模块可以直接回复一段指定的内容。常用于引导、提示',
description: '该模块可以直接回复一段指定的内容。常用于引导、提示',
flowType: FlowModuleTypeEnum.answerNode,
flowType: FlowModuleTypeEnum.answerNode,
inputs: [
inputs: [
Input_Template_TFSwitch,
Input_Template_TFSwitch,
...
@@ -265,7 +283,8 @@ export const AnswerModule: FlowModuleTemplateType = {
...
@@ -265,7 +283,8 @@ export const AnswerModule: FlowModuleTemplateType = {
key: SpecialInputKeyEnum.answerText,
key: SpecialInputKeyEnum.answerText,
value: '',
value: '',
type: FlowInputItemTypeEnum.textarea,
type: FlowInputItemTypeEnum.textarea,
label: '回复的内容'
label: '回复的内容',
description: '可以使用 \\n 来实现换行'
}
}
],
],
outputs: []
outputs: []
...
@@ -309,6 +328,7 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
...
@@ -309,6 +328,7 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
{
{
key: 'systemPrompt',
key: 'systemPrompt',
type: FlowInputItemTypeEnum.textarea,
type: FlowInputItemTypeEnum.textarea,
valueType: FlowValueTypeEnum.string,
label: '系统提示词',
label: '系统提示词',
description:
description:
'你可以添加一些特定内容的介绍,从而更好的识别用户的问题类型。这个内容通常是给模型介绍一个它不知道的内容。',
'你可以添加一些特定内容的介绍,从而更好的识别用户的问题类型。这个内容通常是给模型介绍一个它不知道的内容。',
...
...
client/src/constants/flow/index.ts
View file @
118e3336
import
type
{
BoxProps
}
from
'@chakra-ui/react'
;
export
enum
FlowInputItemTypeEnum
{
export
enum
FlowInputItemTypeEnum
{
systemInput
=
'systemInput'
,
// history, userChatInput, variableInput
systemInput
=
'systemInput'
,
// history, userChatInput, variableInput
input
=
'input'
,
input
=
'input'
,
...
@@ -35,6 +37,36 @@ export enum SpecialInputKeyEnum {
...
@@ -35,6 +37,36 @@ export enum SpecialInputKeyEnum {
'answerText'
=
'text'
'answerText'
=
'text'
}
}
export
enum
FlowValueTypeEnum
{
'string'
=
'string'
,
'number'
=
'number'
,
'boolean'
=
'boolean'
,
'chatHistory'
=
'chatHistory'
,
'kbQuote'
=
'kbQuote'
,
'other'
=
'other'
}
export
const
FlowValueTypeStyle
:
Record
<
`
${
FlowValueTypeEnum
}
`
,
BoxProps
>
=
{
[
FlowValueTypeEnum
.
string
]:
{
background
:
'#36ADEF'
},
[
FlowValueTypeEnum
.
number
]:
{
background
:
'#FB7C3C'
},
[
FlowValueTypeEnum
.
boolean
]:
{
background
:
'#E7D118'
},
[
FlowValueTypeEnum
.
chatHistory
]:
{
background
:
'#00A9A6'
},
[
FlowValueTypeEnum
.
kbQuote
]:
{
background
:
'#A558C9'
},
[
FlowValueTypeEnum
.
other
]:
{
background
:
'#9CA2A8'
}
};
export
const
initModuleType
:
Record
<
string
,
boolean
>
=
{
export
const
initModuleType
:
Record
<
string
,
boolean
>
=
{
[
FlowModuleTypeEnum
.
historyNode
]:
true
,
[
FlowModuleTypeEnum
.
historyNode
]:
true
,
[
FlowModuleTypeEnum
.
questionInput
]:
true
[
FlowModuleTypeEnum
.
questionInput
]:
true
...
...
client/src/constants/flow/inputTemplate.ts
View file @
118e3336
import
{
FlowInputItemType
}
from
'@/types/flow'
;
import
{
FlowInputItemType
}
from
'@/types/flow'
;
import
{
SystemInputEnum
}
from
'../app'
;
import
{
SystemInputEnum
}
from
'../app'
;
import
{
FlowInputItemTypeEnum
}
from
'./index'
;
import
{
FlowInputItemTypeEnum
,
FlowValueTypeEnum
}
from
'./index'
;
export
const
Input_Template_TFSwitch
:
FlowInputItemType
=
{
export
const
Input_Template_TFSwitch
:
FlowInputItemType
=
{
key
:
SystemInputEnum
.
switch
,
key
:
SystemInputEnum
.
switch
,
type
:
FlowInputItemTypeEnum
.
target
,
type
:
FlowInputItemTypeEnum
.
target
,
label
:
'触发器'
label
:
'触发器'
,
valueType
:
FlowValueTypeEnum
.
boolean
};
};
export
const
Input_Template_History
:
FlowInputItemType
=
{
export
const
Input_Template_History
:
FlowInputItemType
=
{
key
:
SystemInputEnum
.
history
,
key
:
SystemInputEnum
.
history
,
type
:
FlowInputItemTypeEnum
.
target
,
type
:
FlowInputItemTypeEnum
.
target
,
label
:
'聊天记录'
label
:
'聊天记录'
,
valueType
:
FlowValueTypeEnum
.
chatHistory
};
};
export
const
Input_Template_UserChatInput
:
FlowInputItemType
=
{
export
const
Input_Template_UserChatInput
:
FlowInputItemType
=
{
key
:
SystemInputEnum
.
userChatInput
,
key
:
SystemInputEnum
.
userChatInput
,
type
:
FlowInputItemTypeEnum
.
target
,
type
:
FlowInputItemTypeEnum
.
target
,
label
:
'用户问题'
,
label
:
'用户问题'
,
required
:
true
required
:
true
,
valueType
:
FlowValueTypeEnum
.
string
};
};
client/src/pages/api/admin/initv4.ts
View file @
118e3336
...
@@ -3,7 +3,6 @@ import type { NextApiRequest, NextApiResponse } from 'next';
...
@@ -3,7 +3,6 @@ import type { NextApiRequest, NextApiResponse } from 'next';
import
{
jsonRes
}
from
'@/service/response'
;
import
{
jsonRes
}
from
'@/service/response'
;
import
{
authUser
}
from
'@/service/utils/auth'
;
import
{
authUser
}
from
'@/service/utils/auth'
;
import
{
connectToDatabase
,
App
}
from
'@/service/mongo'
;
import
{
connectToDatabase
,
App
}
from
'@/service/mongo'
;
import
{
EditFormType
}
from
'@/utils/app'
;
import
{
AppModuleInputItemType
}
from
'@/types/app'
;
import
{
AppModuleInputItemType
}
from
'@/types/app'
;
import
{
FlowModuleTypeEnum
,
SpecialInputKeyEnum
}
from
'@/constants/flow'
;
import
{
FlowModuleTypeEnum
,
SpecialInputKeyEnum
}
from
'@/constants/flow'
;
import
{
TaskResponseKeyEnum
}
from
'@/constants/chat'
;
import
{
TaskResponseKeyEnum
}
from
'@/constants/chat'
;
...
...
client/src/pages/app/detail/components/AdEdit/components/Nodes/NodeCQNode.tsx
View file @
118e3336
...
@@ -11,7 +11,8 @@ import { Handle, Position } from 'reactflow';
...
@@ -11,7 +11,8 @@ import { Handle, Position } from 'reactflow';
import
{
customAlphabet
}
from
'nanoid'
;
import
{
customAlphabet
}
from
'nanoid'
;
const
nanoid
=
customAlphabet
(
'abcdefghijklmnopqrstuvwxyz1234567890'
,
4
);
const
nanoid
=
customAlphabet
(
'abcdefghijklmnopqrstuvwxyz1234567890'
,
4
);
import
MyIcon
from
'@/components/Icon'
;
import
MyIcon
from
'@/components/Icon'
;
import
{
FlowOutputItemTypeEnum
}
from
'@/constants/flow'
;
import
{
FlowOutputItemTypeEnum
,
FlowValueTypeEnum
}
from
'@/constants/flow'
;
import
SourceHandle
from
'../render/SourceHandle'
;
const
NodeCQNode
=
({
const
NodeCQNode
=
({
data
:
{
moduleId
,
inputs
,
outputs
,
onChangeNode
,
...
props
}
data
:
{
moduleId
,
inputs
,
outputs
,
onChangeNode
,
...
props
}
...
@@ -82,19 +83,7 @@ const NodeCQNode = ({
...
@@ -82,19 +83,7 @@ const NodeCQNode = ({
});
});
}
}
}
}
/>
/>
<
Handle
<
SourceHandle
handleKey=
{
item
.
key
}
valueType=
{
FlowValueTypeEnum
.
boolean
}
/>
style=
{
{
top
:
'50%'
,
right
:
'-14px'
,
transform
:
'translate(50%,-50%)'
,
width
:
'12px'
,
height
:
'12px'
,
background
:
'#9CA2A8'
}
}
type=
"source"
id=
{
item
.
key
}
position=
{
Position
.
Right
}
/>
</
Box
>
</
Box
>
</
Box
>
</
Box
>
</
Flex
>
</
Flex
>
...
...
client/src/pages/app/detail/components/AdEdit/components/Nodes/NodeQuestionInput.tsx
View file @
118e3336
import
React
from
'react'
;
import
React
from
'react'
;
import
{
Handle
,
Position
,
NodeProps
}
from
'reactflow'
;
import
{
NodeProps
}
from
'reactflow'
;
import
{
Box
}
from
'@chakra-ui/react'
;
import
{
Box
}
from
'@chakra-ui/react'
;
import
NodeCard
from
'../modules/NodeCard'
;
import
NodeCard
from
'../modules/NodeCard'
;
import
{
FlowModuleItemType
}
from
'@/types/flow'
;
import
{
FlowModuleItemType
}
from
'@/types/flow'
;
import
Container
from
'../modules/Container'
;
import
Container
from
'../modules/Container'
;
import
{
SystemInputEnum
}
from
'@/constants/app'
;
import
{
SystemInputEnum
}
from
'@/constants/app'
;
import
{
FlowValueTypeEnum
}
from
'@/constants/flow'
;
import
SourceHandle
from
'../render/SourceHandle'
;
const
QuestionInputNode
=
({
const
QuestionInputNode
=
({
data
:
{
inputs
,
outputs
,
onChangeNode
,
...
props
}
data
:
{
inputs
,
outputs
,
onChangeNode
,
...
props
}
}:
NodeProps
<
FlowModuleItemType
>
)
=>
{
}:
NodeProps
<
FlowModuleItemType
>
)
=>
{
return
(
return
(
<
NodeCard
minW=
{
'2
2
0px'
}
{
...
props
}
>
<
NodeCard
minW=
{
'2
4
0px'
}
{
...
props
}
>
<
Container
borderTop=
{
'2px solid'
}
borderTopColor=
{
'myGray.200'
}
textAlign=
{
'end'
}
>
<
Container
borderTop=
{
'2px solid'
}
borderTopColor=
{
'myGray.200'
}
textAlign=
{
'end'
}
>
<
Box
>
用户问题
</
Box
>
<
Box
position=
{
'relative'
}
>
<
Handle
用户问题
style=
{
{
<
SourceHandle
bottom
:
'0'
,
handleKey=
{
SystemInputEnum
.
userChatInput
}
right
:
'0'
,
valueType=
{
FlowValueTypeEnum
.
string
}
transform
:
'translate(50%,-5px)'
,
/>
width
:
'12px'
,
</
Box
>
height
:
'12px'
,
background
:
'#9CA2A8'
}
}
id=
{
SystemInputEnum
.
userChatInput
}
type=
"source"
position=
{
Position
.
Right
}
/>
</
Container
>
</
Container
>
</
NodeCard
>
</
NodeCard
>
);
);
...
...
client/src/pages/app/detail/components/AdEdit/components/modules/NodeCard.tsx
View file @
118e3336
...
@@ -37,7 +37,11 @@ const NodeCard = ({
...
@@ -37,7 +37,11 @@ const NodeCard = ({
</
Box
>
</
Box
>
{
description
&&
(
{
description
&&
(
<
MyTooltip
label=
{
description
}
forceShow
>
<
MyTooltip
label=
{
description
}
forceShow
>
<
QuestionOutlineIcon
display=
{
[
'none'
,
'inline'
]
}
ml=
{
1
}
/>
<
QuestionOutlineIcon
display=
{
[
'none'
,
'inline'
]
}
transform=
{
'translateY(-1px)'
}
ml=
{
1
}
/>
</
MyTooltip
>
</
MyTooltip
>
)
}
)
}
<
Box
flex=
{
1
}
/>
<
Box
flex=
{
1
}
/>
...
...
client/src/pages/app/detail/components/AdEdit/components/render/RenderInput.tsx
View file @
118e3336
...
@@ -12,10 +12,10 @@ import {
...
@@ -12,10 +12,10 @@ import {
}
from
'@chakra-ui/react'
;
}
from
'@chakra-ui/react'
;
import
{
FlowInputItemTypeEnum
}
from
'@/constants/flow'
;
import
{
FlowInputItemTypeEnum
}
from
'@/constants/flow'
;
import
{
QuestionOutlineIcon
}
from
'@chakra-ui/icons'
;
import
{
QuestionOutlineIcon
}
from
'@chakra-ui/icons'
;
import
{
Handle
,
Position
}
from
'reactflow'
;
import
MySelect
from
'@/components/Select'
;
import
MySelect
from
'@/components/Select'
;
import
MySlider
from
'@/components/Slider'
;
import
MySlider
from
'@/components/Slider'
;
import
MyTooltip
from
'@/components/MyTooltip'
;
import
MyTooltip
from
'@/components/MyTooltip'
;
import
TargetHandle
from
'./TargetHandle'
;
export
const
Label
=
({
export
const
Label
=
({
required
=
false
,
required
=
false
,
...
@@ -35,7 +35,7 @@ export const Label = ({
...
@@ -35,7 +35,7 @@ export const Label = ({
)
}
)
}
{
description
&&
(
{
description
&&
(
<
MyTooltip
label=
{
description
}
forceShow
>
<
MyTooltip
label=
{
description
}
forceShow
>
<
QuestionOutlineIcon
display=
{
[
'none'
,
'inline'
]
}
ml=
{
1
}
/>
<
QuestionOutlineIcon
display=
{
[
'none'
,
'inline'
]
}
transform=
{
'translateY(-1px)'
}
ml=
{
1
}
/>
</
MyTooltip
>
</
MyTooltip
>
)
}
)
}
</
Box
>
</
Box
>
...
@@ -61,6 +61,10 @@ const RenderBody = ({
...
@@ -61,6 +61,10 @@ const RenderBody = ({
{
!!
item
.
label
&&
(
{
!!
item
.
label
&&
(
<
Label
required=
{
item
.
required
}
description=
{
item
.
description
}
>
<
Label
required=
{
item
.
required
}
description=
{
item
.
description
}
>
{
item
.
label
}
{
item
.
label
}
{
(
item
.
type
===
FlowInputItemTypeEnum
.
target
||
item
.
valueType
)
&&
(
<
TargetHandle
handleKey=
{
item
.
key
}
valueType=
{
item
.
valueType
}
/>
)
}
</
Label
>
</
Label
>
)
}
)
}
<
Box
mt=
{
2
}
className=
{
'nodrag'
}
>
<
Box
mt=
{
2
}
className=
{
'nodrag'
}
>
...
@@ -148,22 +152,6 @@ const RenderBody = ({
...
@@ -148,22 +152,6 @@ const RenderBody = ({
{
item
.
type
===
FlowInputItemTypeEnum
.
custom
&&
CustomComponent
[
item
.
key
]
&&
(
{
item
.
type
===
FlowInputItemTypeEnum
.
custom
&&
CustomComponent
[
item
.
key
]
&&
(
<>
{
CustomComponent
[
item
.
key
]({
...
item
})
}
</>
<>
{
CustomComponent
[
item
.
key
]({
...
item
})
}
</>
)
}
)
}
{
item
.
type
===
FlowInputItemTypeEnum
.
target
&&
(
<
Handle
style=
{
{
top
:
'50%'
,
left
:
'-14px'
,
transform
:
'translate(-50%,-50%)'
,
width
:
'12px'
,
height
:
'12px'
,
background
:
'#9CA2A8'
}
}
id=
{
item
.
key
}
type=
"target"
position=
{
Position
.
Left
}
onConnect=
{
(
params
)
=>
console
.
log
(
'handle onConnect'
,
params
)
}
/>
)
}
</
Box
>
</
Box
>
</
Box
>
</
Box
>
)
)
...
...
client/src/pages/app/detail/components/AdEdit/components/render/RenderOutput.tsx
View file @
118e3336
...
@@ -5,6 +5,7 @@ import { FlowOutputItemTypeEnum } from '@/constants/flow';
...
@@ -5,6 +5,7 @@ import { FlowOutputItemTypeEnum } from '@/constants/flow';
import
{
QuestionOutlineIcon
}
from
'@chakra-ui/icons'
;
import
{
QuestionOutlineIcon
}
from
'@chakra-ui/icons'
;
import
{
Handle
,
Position
}
from
'reactflow'
;
import
{
Handle
,
Position
}
from
'reactflow'
;
import
MyTooltip
from
'@/components/MyTooltip'
;
import
MyTooltip
from
'@/components/MyTooltip'
;
import
SourceHandle
from
'./SourceHandle'
;
const
Label
=
({
const
Label
=
({
children
,
children
,
...
@@ -16,7 +17,7 @@ const Label = ({
...
@@ -16,7 +17,7 @@ const Label = ({
<
Flex
as=
{
'label'
}
justifyContent=
{
'right'
}
alignItems=
{
'center'
}
position=
{
'relative'
}
>
<
Flex
as=
{
'label'
}
justifyContent=
{
'right'
}
alignItems=
{
'center'
}
position=
{
'relative'
}
>
{
description
&&
(
{
description
&&
(
<
MyTooltip
label=
{
description
}
forceShow
>
<
MyTooltip
label=
{
description
}
forceShow
>
<
QuestionOutlineIcon
display=
{
[
'none'
,
'inline'
]
}
mr=
{
1
}
/>
<
QuestionOutlineIcon
display=
{
[
'none'
,
'inline'
]
}
transform=
{
'translateY(-1px)'
}
mr=
{
1
}
/>
</
MyTooltip
>
</
MyTooltip
>
)
}
)
}
{
children
}
{
children
}
...
@@ -33,19 +34,7 @@ const RenderBody = ({ flowOutputList }: { flowOutputList: FlowOutputItemType[] }
...
@@ -33,19 +34,7 @@ const RenderBody = ({ flowOutputList }: { flowOutputList: FlowOutputItemType[] }
<
Label
description=
{
item
.
description
}
>
{
item
.
label
}
</
Label
>
<
Label
description=
{
item
.
description
}
>
{
item
.
label
}
</
Label
>
<
Box
mt=
{
FlowOutputItemTypeEnum
.
answer
?
0
:
2
}
className=
{
'nodrag'
}
>
<
Box
mt=
{
FlowOutputItemTypeEnum
.
answer
?
0
:
2
}
className=
{
'nodrag'
}
>
{
item
.
type
===
FlowOutputItemTypeEnum
.
source
&&
(
{
item
.
type
===
FlowOutputItemTypeEnum
.
source
&&
(
<
Handle
<
SourceHandle
handleKey=
{
item
.
key
}
valueType=
{
item
.
valueType
}
/>
style=
{
{
top
:
'50%'
,
right
:
'-14px'
,
transform
:
'translate(50%,-50%)'
,
width
:
'12px'
,
height
:
'12px'
,
background
:
'#9CA2A8'
}
}
type=
"source"
id=
{
item
.
key
}
position=
{
Position
.
Right
}
/>
)
}
)
}
</
Box
>
</
Box
>
</
Box
>
</
Box
>
...
...
client/src/pages/app/detail/components/AdEdit/components/render/SourceHandle.tsx
0 → 100644
View file @
118e3336
import
React
,
{
useMemo
}
from
'react'
;
import
{
Box
,
BoxProps
}
from
'@chakra-ui/react'
;
import
{
Handle
,
Position
}
from
'reactflow'
;
import
{
FlowValueTypeEnum
,
FlowValueTypeStyle
}
from
'@/constants/flow'
;
interface
Props
extends
BoxProps
{
handleKey
:
string
;
valueType
?:
`
${
FlowValueTypeEnum
}
`
;
}
const
SourceHandle
=
({
handleKey
,
valueType
,
...
props
}:
Props
)
=>
{
const
valueStyle
=
useMemo
(
()
=>
valueType
?
FlowValueTypeStyle
[
valueType
]
:
(
FlowValueTypeStyle
[
FlowValueTypeEnum
.
other
]
as
any
),
[]
);
return
(
<
Box
position=
{
'absolute'
}
top=
{
'50%'
}
right=
{
'-16px'
}
transform=
{
'translate(50%,-50%)'
}
{
...
props
}
>
<
Handle
style=
{
{
width
:
'12px'
,
height
:
'12px'
,
...
valueStyle
}
}
type=
"source"
id=
{
handleKey
}
position=
{
Position
.
Right
}
/>
</
Box
>
);
};
export
default
SourceHandle
;
client/src/pages/app/detail/components/AdEdit/components/render/TargetHandle.tsx
0 → 100644
View file @
118e3336
import
React
,
{
useMemo
}
from
'react'
;
import
{
Box
,
BoxProps
}
from
'@chakra-ui/react'
;
import
{
Handle
,
OnConnect
,
Position
}
from
'reactflow'
;
import
{
FlowValueTypeEnum
,
FlowValueTypeStyle
}
from
'@/constants/flow'
;
interface
Props
extends
BoxProps
{
handleKey
:
string
;
valueType
?:
`
${
FlowValueTypeEnum
}
`
;
onConnect
?:
OnConnect
;
}
const
TargetHandle
=
({
handleKey
,
valueType
,
onConnect
,
...
props
}:
Props
)
=>
{
const
valueStyle
=
useMemo
(
()
=>
valueType
?
FlowValueTypeStyle
[
valueType
]
:
(
FlowValueTypeStyle
[
FlowValueTypeEnum
.
other
]
as
any
),
[]
);
return
(
<
Box
position=
{
'absolute'
}
top=
{
'50%'
}
left=
{
'-16px'
}
transform=
{
'translate(50%,-50%)'
}
{
...
props
}
>
<
Handle
style=
{
{
width
:
'12px'
,
height
:
'12px'
,
...
valueStyle
}
}
type=
"target"
id=
{
handleKey
}
datatype=
{
valueStyle
}
position=
{
Position
.
Left
}
/>
</
Box
>
);
};
export
default
TargetHandle
;
client/src/service/moduleDispatch/chat/oneapi.ts
View file @
118e3336
...
@@ -30,6 +30,7 @@ export type ChatProps = {
...
@@ -30,6 +30,7 @@ export type ChatProps = {
export
type
ChatResponse
=
{
export
type
ChatResponse
=
{
[
TaskResponseKeyEnum
.
answerText
]:
string
;
[
TaskResponseKeyEnum
.
answerText
]:
string
;
[
TaskResponseKeyEnum
.
responseData
]:
ChatHistoryItemResType
;
[
TaskResponseKeyEnum
.
responseData
]:
ChatHistoryItemResType
;
finish
:
boolean
;
};
};
/* request openai chat */
/* request openai chat */
...
@@ -143,7 +144,8 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
...
@@ -143,7 +144,8 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
maxToken
,
maxToken
,
quoteList
:
filterQuoteQA
,
quoteList
:
filterQuoteQA
,
completeMessages
completeMessages
}
},
finish
:
true
};
};
};
};
...
...
client/src/types/flow.d.ts
View file @
118e3336
import
{
import
{
FlowBodyItemTypeEnum
,
FlowBodyItemTypeEnum
,
FlowInputItemTypeEnum
,
FlowInputItemTypeEnum
,
FlowOutputItemTypeEnum
FlowOutputItemTypeEnum
,
FlowValueTypeEnum
}
from
'@/constants/flow'
;
}
from
'@/constants/flow'
;
import
{
Connection
}
from
'reactflow'
;
import
{
Connection
}
from
'reactflow'
;
import
type
{
AppModuleItemType
}
from
'./app'
;
import
type
{
AppModuleItemType
}
from
'./app'
;
...
@@ -18,6 +19,7 @@ export type FlowModuleItemChangeProps = {
...
@@ -18,6 +19,7 @@ export type FlowModuleItemChangeProps = {
export
type
FlowInputItemType
=
{
export
type
FlowInputItemType
=
{
key
:
string
;
// 字段名
key
:
string
;
// 字段名
value
?:
any
;
value
?:
any
;
valueType
?:
`
${
FlowValueTypeEnum
}
`
;
type
:
`
${
FlowInputItemTypeEnum
}
`
;
type
:
`
${
FlowInputItemTypeEnum
}
`
;
label
:
string
;
label
:
string
;
connected
?:
boolean
;
connected
?:
boolean
;
...
@@ -39,6 +41,7 @@ export type FlowOutputItemType = {
...
@@ -39,6 +41,7 @@ export type FlowOutputItemType = {
key
:
string
;
// 字段名
key
:
string
;
// 字段名
label
:
string
;
label
:
string
;
description
?:
string
;
description
?:
string
;
valueType
?:
`
${
FlowValueTypeEnum
}
`
;
type
:
`
${
FlowOutputItemTypeEnum
}
`
;
type
:
`
${
FlowOutputItemTypeEnum
}
`
;
targets
:
FlowOutputTargetItemType
[];
targets
:
FlowOutputTargetItemType
[];
};
};
...
...
client/src/utils/adapt.ts
View file @
118e3336
...
@@ -76,10 +76,7 @@ export const appModule2FlowNode = ({
...
@@ -76,10 +76,7 @@ export const appModule2FlowNode = ({
// replace item data
// replace item data
const
moduleItem
:
FlowModuleItemType
=
{
const
moduleItem
:
FlowModuleItemType
=
{
...
item
,
...
item
,
logo
:
template
.
logo
,
...
template
,
name
:
template
.
name
,
intro
:
template
.
intro
,
url
:
template
.
url
,
inputs
:
template
.
inputs
.
map
((
templateInput
)
=>
{
inputs
:
template
.
inputs
.
map
((
templateInput
)
=>
{
// use latest inputs
// use latest inputs
const
itemInput
=
item
.
inputs
.
find
((
item
)
=>
item
.
key
===
templateInput
.
key
)
||
templateInput
;
const
itemInput
=
item
.
inputs
.
find
((
item
)
=>
item
.
key
===
templateInput
.
key
)
||
templateInput
;
...
...
docSite/docs/datasets/prompt.md
0 → 100644
View file @
118e3336
# 提示词示例
## 客服
```
您好您将扮演万千紧固件公司的售前客服。在第一次咨询中,您需要获取客户的联系人姓名和手机号码,并了解客户是终端生产企业还是工贸经销商。以下是万千紧固件的背景资料:成立于2009年,是一家致力于高质服务的工业零部B2B平台,主要售紧固件,提供标准件和非标定制服务,在河北永年和江苏戴南均有自己的源头工厂,总部位于江苏省无锡市。
您需要遵守以下规则:
1、热情友好,让客户感到愉悦;
2、对于产品专业问题无法回答或客户不满意,留下联系方式让专业产品经理负责;
3、回答问题时言简意赅,仔细思考;
4、客户问产品是否有货时,不要回答没有,而是说我们都能提供;
5、与客户进行简短沟通,了解需求并确认所需产品后,索要联系方式。
样本示例1:
客户:在吗?
客服:在的,请问您需要咨询什么产品?
客户:防盗螺栓有吗?
客服:有的,我们提供全品类的紧固件产品,请告诉我具体的型号和用途。
客户:用在铁塔机器上的,2040304不锈钢
客服:请问需要多少件?
客户:大概10万颗左右吧
客户:给我个报价,优惠些,长期合作
客服:非常抱歉,报价需要我们专业的产品同事,您能留下联系方式吗?我会安排他们立即与您联系。
客户:王先,13928916752今天能联系么
客服:可以的,我们的同事会在1个小时内与您联系,请注意接听来自无锡的电话。谢谢您的咨询。
样本示例2:
客户:请问一下这个螺栓有没有33长度的?
客服:您好,我是客服小万,请问您需要的是哪种螺栓?能说得更具体一些吗?
客户:圆头方颈。
客服:头部多大?
客户:13。
客户:M6的。
客服:您要的是哪个材质的呢?
客户:碳钢的,强度高一点。
客服:您需要多少个呢?
客户:大约2000个左右。
客服:方便留下您的联系方式吗?
客服:我会让同事在上午与您确认并回复。
客户:18217699040。
客服:请问您的姓氏是?
客户:王。
客服:好的。
客户:谢谢。
样本示例3:
客户:你们是生产还是贸易?
客服:亲,感谢您的咨询。我们既生产也贸易,同时接受标准件和非标定制的订单。请问您需要采购什么产品?
客户:SPR25x100L铜套的304材质螺母M64。
客户:我想找源头工厂。
客服:亲,我们就是源头工厂哦!请问您是关心价格还是质量呢?我们万千是国内大品牌,价格实惠,质量和交期都有保障。
客户:工厂放心点,经销商门道太多。
客服:亲,您可以放心,我们的产品质量有保障,如有不满意可退换;有问题我们也有专属客服经理24小时处理。
客服:请问您具体需要多少数量呢?
客户:2456个。
客户:什么时候能给出报价?我这边比较着急使用。
客服:亲,请留下您的联系方式,我会让我们专业的产品同事与您联系。
客户:13928956789,李。
样本示例4:
客户:你好,在吗?
客服:在的。
客服:请问您需要什么产品?
客户:卡箍有吗?
客服:有的,您需要哪一种?
客户:我是用在电线杆上的。
客户:我需要200个。
客服:好的,您需要什么材质的?
客户:有图片吗?我想看看是不是我需要的那种,材质无所谓。
客服:好的,方便加您微信吗?在线上不方便发图片,加微信后我会给您发送图片以进行确认。
客户:您的微信是多少?我加您。
客服:好的,我的微信是18626076792,您可以添加一下。您也可以直接拨打电话与我们联系。
客户:已添加,请通过微信沟通。
客服:好的,已通过,我需要记录一下,请问您的电话方便吗?
客户:187628100000。
服:请问您的姓氏是?
客户:陈。
客服:好的。
客户:谢谢。
样本示例5:
户:87322.5。
客服:好的,您是要扁圆头半空心铆钉吗?您需要具体什么材质的呢?
客户:材质无所谓。您们的最低起订量是多少?
客服:起订量这边需要帮您查询一下系统。您是只要规格,材质无所谓吗?
客户:是的,因为不好买。
客服:好的,这边稍后查一下系统,确认是否有现货。如果没有现货,是否可以接受定制?我们公司也支持定制服务。
客户:定制需要多少起订量?您能帮我询问一下不同材质的要求吗?
客服:好的,方便留下您的联系方式吗?稍后我们会安排专业的同事与您联系,直接对接沟通。
客户:18190818931。
客服:请问您的姓氏是?
客户:杨。
客服:好的,请稍等。
样品示例6
客户:不锈钢201 M87,单价多少?
客服说:你好,请问您需要的是哪一种螺丝?
客户:外六角螺栓
客服说:好的,你需要多少啊?我们量大优惠越大
客户:10000左右
客服说:好的,只有这一种产品需要帮你报价吗,还有其他的产品需要一并帮你确认价格吗?
客户:全牙201不锈钢 M825
客服说:好的,您总共有几种产品需要报价?
客户:十几种
```
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