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
d057ba29
authored
May 06, 2024
by
Archer
Committed by
GitHub
May 06, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: custom feedback plugin (#1365)
parent
b500631a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
149 additions
and
267 deletions
+149
-267
packages/service/core/workflow/dispatch/index.ts
+30
-16
projects/app/data/pluginTemplates/customFeedback.json
+119
-250
projects/app/src/service/support/wallet/usage/push.ts
+0
-1
No files found.
packages/service/core/workflow/dispatch/index.ts
View file @
d057ba29
...
@@ -69,21 +69,25 @@ const callbackMap: Record<`${FlowNodeTypeEnum}`, Function> = {
...
@@ -69,21 +69,25 @@ const callbackMap: Record<`${FlowNodeTypeEnum}`, Function> = {
[
FlowNodeTypeEnum
.
globalVariable
]:
()
=>
Promise
.
resolve
()
[
FlowNodeTypeEnum
.
globalVariable
]:
()
=>
Promise
.
resolve
()
};
};
/* running */
type
Props
=
ChatDispatchProps
&
{
export
async
function
dispatchWorkFlow
({
res
,
runtimeNodes
=
[],
runtimeEdges
=
[],
histories
=
[],
variables
=
{},
user
,
stream
=
false
,
detail
=
false
,
...
props
}:
ChatDispatchProps
&
{
runtimeNodes
:
RuntimeNodeItemType
[];
runtimeNodes
:
RuntimeNodeItemType
[];
runtimeEdges
:
RuntimeEdgeItemType
[];
runtimeEdges
:
RuntimeEdgeItemType
[];
}):
Promise
<
DispatchFlowResponse
>
{
};
/* running */
export
async
function
dispatchWorkFlow
(
data
:
Props
):
Promise
<
DispatchFlowResponse
>
{
let
{
res
,
runtimeNodes
=
[],
runtimeEdges
=
[],
histories
=
[],
variables
=
{},
user
,
stream
=
false
,
detail
=
false
,
...
props
}
=
data
;
// set sse response headers
// set sse response headers
if
(
stream
&&
res
)
{
if
(
stream
&&
res
)
{
res
.
setHeader
(
'Content-Type'
,
'text/event-stream;charset=utf-8'
);
res
.
setHeader
(
'Content-Type'
,
'text/event-stream;charset=utf-8'
);
...
@@ -93,7 +97,7 @@ export async function dispatchWorkFlow({
...
@@ -93,7 +97,7 @@ export async function dispatchWorkFlow({
}
}
variables
=
{
variables
=
{
...
getSystemVariable
(
{
timezone
:
user
.
timezone
}
),
...
getSystemVariable
(
data
),
...
variables
...
variables
};
};
...
@@ -384,9 +388,19 @@ export function responseStatus({
...
@@ -384,9 +388,19 @@ export function responseStatus({
}
}
/* get system variable */
/* get system variable */
export
function
getSystemVariable
({
timezone
}:
{
timezone
:
string
})
{
export
function
getSystemVariable
({
user
,
appId
,
chatId
,
responseChatItemId
,
histories
=
[]
}:
Props
)
{
return
{
return
{
cTime
:
getSystemTime
(
timezone
)
appId
,
chatId
,
responseChatItemId
,
histories
,
cTime
:
getSystemTime
(
user
.
timezone
)
};
};
}
}
...
...
projects/app/data/pluginTemplates/customFeedback.json
View file @
d057ba29
...
@@ -7,336 +7,205 @@
...
@@ -7,336 +7,205 @@
"showStatus"
:
false
,
"showStatus"
:
false
,
"isTool"
:
false
,
"isTool"
:
false
,
"weight"
:
0
,
"weight"
:
0
,
"
modul
es"
:
[
"
nod
es"
:
[
{
{
"
moduleId"
:
"w90mfp
"
,
"
nodeId"
:
"lmpb9v2lo2lk
"
,
"name"
:
"定义插件输入"
,
"name"
:
"定义插件输入"
,
"flowType"
:
"pluginInput"
,
"intro"
:
"自定义配置外部输入,使用插件时,仅暴露自定义配置的输入"
,
"avatar"
:
"/imgs/workflow/input.png"
,
"flowNodeType"
:
"pluginInput"
,
"showStatus"
:
false
,
"showStatus"
:
false
,
"position"
:
{
"position"
:
{
"x"
:
515.1887815471657
,
"x"
:
616.4226348688949
,
"y"
:
-16
9.04905809653783
"y"
:
-16
5.05298493910115
},
},
"inputs"
:
[
"inputs"
:
[
{
{
"key"
:
"
defaultFeedback
"
,
"key"
:
"
system_addInputParam
"
,
"valueType"
:
"
string
"
,
"valueType"
:
"
dynamic
"
,
"label"
:
"
默认反馈内容
"
,
"label"
:
"
动态外部数据
"
,
"
type"
:
"textarea"
,
"
renderTypeList"
:
[
"addInputParam"
]
,
"required"
:
false
,
"required"
:
false
,
"description"
:
""
,
"description"
:
""
,
"edit"
:
true
,
"canEdit"
:
true
,
"value"
:
""
,
"editField"
:
{
"editField"
:
{
"key"
:
true
,
"key"
:
true
"name"
:
true
,
"description"
:
true
,
"required"
:
true
,
"dataType"
:
true
,
"inputType"
:
true
},
},
"connected"
:
true
"dynamicParamDefaultValue"
:
{
"inputType"
:
"reference"
,
"valueType"
:
"string"
,
"required"
:
true
}
},
},
{
{
"key"
:
"
customFeedback
"
,
"key"
:
"
反馈内容
"
,
"valueType"
:
"string"
,
"valueType"
:
"string"
,
"label"
:
"自定义反馈内容"
,
"label"
:
"反馈内容"
,
"type"
:
"target"
,
"renderTypeList"
:
[
"textarea"
],
"required"
:
false
,
"description"
:
""
,
"description"
:
""
,
"edit"
:
true
,
"canEdit"
:
true
,
"value"
:
""
,
"editField"
:
{
"editField"
:
{
"key"
:
true
,
"key"
:
true
"name"
:
true
,
"description"
:
true
,
"required"
:
true
,
"dataType"
:
true
,
"inputType"
:
true
},
},
"connected"
:
true
"maxLength"
:
""
,
"dynamicParamDefaultValue"
:
{
"inputType"
:
"reference"
,
"valueType"
:
"string"
,
"required"
:
true
}
}
}
],
],
"outputs"
:
[
"outputs"
:
[
{
{
"key"
:
"defaultFeedback"
,
"id"
:
"ILc8GS7iU53M"
,
"key"
:
"反馈内容"
,
"valueType"
:
"string"
,
"valueType"
:
"string"
,
"label"
:
"默认反馈内容"
,
"label"
:
"反馈内容"
,
"type"
:
"source"
,
"type"
:
"static"
"edit"
:
true
,
"targets"
:
[
{
"moduleId"
:
"49de3g"
,
"key"
:
"defaultFeedback"
}
]
},
},
{
{
"key"
:
"customFeedback"
,
"id"
:
"2LCxDnOSculb"
,
"valueType"
:
"string"
,
"key"
:
"system_addInputParam"
,
"label"
:
"自定义反馈内容"
,
"valueType"
:
"dynamic"
,
"type"
:
"source"
,
"label"
:
"动态外部数据"
,
"edit"
:
true
,
"type"
:
"static"
"targets"
:
[
{
"moduleId"
:
"49de3g"
,
"key"
:
"customFeedback"
}
]
}
}
]
]
},
},
{
{
"moduleId"
:
"49de3g"
,
"nodeId"
:
"i7uow4wj2wdp"
,
"name"
:
"HTTP模块"
,
"name"
:
"定义插件输出"
,
"flowType"
:
"httpRequest468"
,
"intro"
:
"自定义配置外部输出,使用插件时,仅暴露自定义配置的输出"
,
"avatar"
:
"/imgs/workflow/output.png"
,
"flowNodeType"
:
"pluginOutput"
,
"showStatus"
:
false
,
"position"
:
{
"x"
:
1607.7142331269126
,
"y"
:
-151.8669210746189
},
"inputs"
:
[],
"outputs"
:
[]
},
{
"nodeId"
:
"CRT7oIEU8v2P"
,
"name"
:
"HTTP 请求"
,
"intro"
:
"可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)"
,
"avatar"
:
"/imgs/workflow/http.png"
,
"flowNodeType"
:
"httpRequest468"
,
"showStatus"
:
true
,
"showStatus"
:
true
,
"position"
:
{
"position"
:
{
"x"
:
10
86.8929621216014
,
"x"
:
10
70.8458389994719
,
"y"
:
-4
51.755000977350
6
"y"
:
-4
15.0902255540783
6
},
},
"inputs"
:
[
"inputs"
:
[
{
{
"key"
:
"switch"
,
"key"
:
"system_addInputParam"
,
"type"
:
"target"
,
"renderTypeList"
:
[
"addInputParam"
],
"label"
:
"core.module.input.label.switch"
,
"valueType"
:
"dynamic"
,
"description"
:
"core.module.input.description.Trigger"
,
"label"
:
""
,
"valueType"
:
"any"
,
"required"
:
false
,
"showTargetInApp"
:
true
,
"description"
:
"core.module.input.description.HTTP Dynamic Input"
,
"showTargetInPlugin"
:
true
,
"editField"
:
{
"connected"
:
false
"key"
:
true
,
"valueType"
:
true
},
"value"
:
[
"lmpb9v2lo2lk"
,
"2LCxDnOSculb"
]
},
{
"key"
:
"customFeedback"
,
"valueType"
:
"string"
,
"label"
:
"customFeedback"
,
"renderTypeList"
:
[
"reference"
],
"description"
:
""
,
"canEdit"
:
true
,
"editField"
:
{
"key"
:
true
,
"valueType"
:
true
},
"value"
:
[
"lmpb9v2lo2lk"
,
"ILc8GS7iU53M"
]
},
},
{
{
"key"
:
"system_httpMethod"
,
"key"
:
"system_httpMethod"
,
"
type"
:
"custom"
,
"
renderTypeList"
:
[
"custom"
]
,
"valueType"
:
"string"
,
"valueType"
:
"string"
,
"label"
:
""
,
"label"
:
""
,
"value"
:
"POST"
,
"value"
:
"POST"
,
"list"
:
[
"required"
:
true
{
"label"
:
"GET"
,
"value"
:
"GET"
},
{
"label"
:
"POST"
,
"value"
:
"POST"
}
],
"required"
:
true
,
"showTargetInApp"
:
false
,
"showTargetInPlugin"
:
false
,
"connected"
:
false
},
},
{
{
"key"
:
"system_httpReqUrl"
,
"key"
:
"system_httpReqUrl"
,
"
type"
:
"hidden"
,
"
renderTypeList"
:
[
"hidden"
]
,
"valueType"
:
"string"
,
"valueType"
:
"string"
,
"label"
:
""
,
"label"
:
""
,
"description"
:
"core.module.input.description.Http Request Url"
,
"description"
:
"core.module.input.description.Http Request Url"
,
"placeholder"
:
"https://api.ai.com/getInventory"
,
"placeholder"
:
"https://api.ai.com/getInventory"
,
"required"
:
false
,
"required"
:
false
,
"showTargetInApp"
:
false
,
"value"
:
"/api/plugins/customFeedback"
"showTargetInPlugin"
:
false
,
"value"
:
"/api/plugins/customFeedback"
,
"connected"
:
false
},
},
{
{
"key"
:
"system_httpHeader"
,
"key"
:
"system_httpHeader"
,
"
type"
:
"custom"
,
"
renderTypeList"
:
[
"custom"
]
,
"valueType"
:
"any"
,
"valueType"
:
"any"
,
"value"
:
""
,
"value"
:
[]
,
"label"
:
""
,
"label"
:
""
,
"description"
:
"core.module.input.description.Http Request Header"
,
"description"
:
"core.module.input.description.Http Request Header"
,
"placeholder"
:
"core.module.input.description.Http Request Header"
,
"placeholder"
:
"core.module.input.description.Http Request Header"
,
"required"
:
false
,
"required"
:
false
"showTargetInApp"
:
false
,
"showTargetInPlugin"
:
false
,
"connected"
:
false
},
},
{
{
"key"
:
"system_httpParams"
,
"key"
:
"system_httpParams"
,
"
type"
:
"hidden"
,
"
renderTypeList"
:
[
"hidden"
]
,
"valueType"
:
"any"
,
"valueType"
:
"any"
,
"value"
:
[],
"value"
:
[],
"label"
:
""
,
"label"
:
""
,
"required"
:
false
,
"required"
:
false
"showTargetInApp"
:
false
,
"showTargetInPlugin"
:
false
,
"connected"
:
false
},
},
{
{
"key"
:
"system_httpJsonBody"
,
"key"
:
"system_httpJsonBody"
,
"
type"
:
"hidden"
,
"
renderTypeList"
:
[
"hidden"
]
,
"valueType"
:
"any"
,
"valueType"
:
"any"
,
"value"
:
"{
\r\n
\"
appId
\"
:
\"
{{appId}}
\"
,
\r\n
\"
chatId
\"
:
\"
{{chatId}}
\"
,
\r\n
\"
responseChatItemId
\"
:
\"
{{responseChatItemId}}
\"
,
\r\n
\"
defaultFeedback
\"
:
\"
{{defaultFeedback}}
\"
,
\r\n
\"
customFeedback
\"
:
\"
{{customFeedback}}
\"
\r\n
}"
,
"value"
:
"{
\r\n
\"
customFeedback
\"
:
\"
{{customFeedback}}
\"
,
\r\n
\"
system_addInputParam
\"
: {{system_addInputParam}}
\r\n
}"
,
"label"
:
""
,
"label"
:
""
,
"required"
:
false
,
"required"
:
false
"showTargetInApp"
:
false
,
"showTargetInPlugin"
:
false
,
"connected"
:
false
},
{
"key"
:
"DYNAMIC_INPUT_KEY"
,
"type"
:
"target"
,
"valueType"
:
"any"
,
"label"
:
"core.workflow.inputType.dynamicTargetInput"
,
"description"
:
"core.module.input.description.dynamic input"
,
"required"
:
false
,
"showTargetInApp"
:
false
,
"showTargetInPlugin"
:
true
,
"hideInApp"
:
true
,
"connected"
:
false
},
{
"valueType"
:
"string"
,
"label"
:
"defaultFeedback"
,
"type"
:
"target"
,
"required"
:
true
,
"description"
:
""
,
"edit"
:
true
,
"editField"
:
{
"key"
:
true
,
"name"
:
true
,
"description"
:
true
,
"required"
:
true
,
"dataType"
:
true
},
"connected"
:
true
,
"key"
:
"defaultFeedback"
},
{
"key"
:
"customFeedback"
,
"valueType"
:
"string"
,
"label"
:
"customFeedback"
,
"type"
:
"target"
,
"required"
:
true
,
"description"
:
""
,
"edit"
:
true
,
"editField"
:
{
"key"
:
true
,
"name"
:
true
,
"description"
:
true
,
"required"
:
true
,
"dataType"
:
true
},
"connected"
:
true
},
{
"key"
:
"system_addInputParam"
,
"type"
:
"addInputParam"
,
"valueType"
:
"any"
,
"label"
:
""
,
"required"
:
false
,
"showTargetInApp"
:
false
,
"showTargetInPlugin"
:
false
,
"editField"
:
{
"key"
:
true
,
"name"
:
true
,
"description"
:
true
,
"required"
:
true
,
"dataType"
:
true
},
"defaultEditField"
:
{
"label"
:
""
,
"key"
:
""
,
"description"
:
""
,
"inputType"
:
"target"
,
"valueType"
:
"string"
,
"required"
:
true
},
"connected"
:
false
}
}
],
],
"outputs"
:
[
"outputs"
:
[
{
{
"key"
:
"finish"
,
"id"
:
"system_addOutputParam"
,
"label"
:
"core.module.output.label.running done"
,
"description"
:
"core.module.output.description.running done"
,
"valueType"
:
"boolean"
,
"type"
:
"hidden"
,
"targets"
:
[]
},
{
"key"
:
"system_addOutputParam"
,
"key"
:
"system_addOutputParam"
,
"type"
:
"
addOutputParam
"
,
"type"
:
"
dynamic
"
,
"valueType"
:
"
any
"
,
"valueType"
:
"
dynamic
"
,
"label"
:
""
,
"label"
:
""
,
"targets"
:
[],
"editField"
:
{
"editField"
:
{
"key"
:
true
,
"key"
:
true
,
"name"
:
true
,
"valueType"
:
true
"description"
:
true
,
"dataType"
:
true
},
"defaultEditField"
:
{
"label"
:
""
,
"key"
:
""
,
"description"
:
""
,
"outputType"
:
"source"
,
"valueType"
:
"string"
}
}
},
},
{
{
"type"
:
"source"
,
"id"
:
"httpRawResponse"
,
"valueType"
:
"string"
,
"key"
:
"httpRawResponse"
,
"label"
:
"response"
,
"label"
:
"原始响应"
,
"description"
:
""
,
"description"
:
"HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。"
,
"edit"
:
true
,
"valueType"
:
"any"
,
"editField"
:
{
"type"
:
"static"
"key"
:
true
,
"name"
:
true
,
"description"
:
true
,
"dataType"
:
true
},
"targets"
:
[
{
"moduleId"
:
"s15f3v"
,
"key"
:
"text"
}
],
"key"
:
"response"
}
}
]
]
}
],
"edges"
:
[
{
"source"
:
"lmpb9v2lo2lk"
,
"target"
:
"CRT7oIEU8v2P"
,
"sourceHandle"
:
"lmpb9v2lo2lk-source-right"
,
"targetHandle"
:
"CRT7oIEU8v2P-target-left"
},
},
{
{
"moduleId"
:
"s15f3v"
,
"source"
:
"CRT7oIEU8v2P"
,
"name"
:
"指定回复"
,
"target"
:
"i7uow4wj2wdp"
,
"flowType"
:
"answerNode"
,
"sourceHandle"
:
"CRT7oIEU8v2P-source-right"
,
"position"
:
{
"targetHandle"
:
"i7uow4wj2wdp-target-left"
"x"
:
1705.6337348182756
,
"y"
:
-37.53826066726282
},
"inputs"
:
[
{
"key"
:
"switch"
,
"type"
:
"target"
,
"label"
:
"core.module.input.label.switch"
,
"description"
:
"core.module.input.description.Trigger"
,
"valueType"
:
"any"
,
"showTargetInApp"
:
true
,
"showTargetInPlugin"
:
true
,
"connected"
:
false
},
{
"key"
:
"text"
,
"type"
:
"textarea"
,
"valueType"
:
"any"
,
"label"
:
"core.module.input.label.Response content"
,
"description"
:
"core.module.input.description.Response content"
,
"placeholder"
:
"core.module.input.description.Response content"
,
"showTargetInApp"
:
true
,
"showTargetInPlugin"
:
true
,
"connected"
:
true
}
],
"outputs"
:
[
{
"key"
:
"finish"
,
"label"
:
"core.module.output.label.running done"
,
"description"
:
"core.module.output.description.running done"
,
"valueType"
:
"boolean"
,
"type"
:
"hidden"
,
"targets"
:
[]
}
]
}
}
]
]
}
}
projects/app/src/service/support/wallet/usage/push.ts
View file @
d057ba29
...
@@ -42,7 +42,6 @@ export const pushChatUsage = ({
...
@@ -42,7 +42,6 @@ export const pushChatUsage = ({
addLog
.
info
(
`finish completions`
,
{
addLog
.
info
(
`finish completions`
,
{
source
,
source
,
teamId
,
teamId
,
tmbId
,
totalPoints
totalPoints
});
});
return
{
totalPoints
};
return
{
totalPoints
};
...
...
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