Skip to content

Commit 9f33729

Browse files
authored
feat(core): 添加 sleep 插件 (#3583)
(cherry picked from commit 09bdc63)
1 parent a8d456f commit 9f33729

File tree

5 files changed

+396
-1
lines changed

5 files changed

+396
-1
lines changed

packages/plugins/register.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const packagePluginList = [
2828
'databaseConnection',
2929
'Doc2X',
3030
'Doc2X/PDF2text',
31-
'searchXNG'
31+
'searchXNG',
32+
'sleep'
3233
];
3334

3435
export const list = [...staticPluginList, ...packagePluginList];
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
type Props = {
2+
ms: number;
3+
};
4+
type Response = Promise<{
5+
result: any;
6+
}>;
7+
8+
const main = async ({ ms }: Props): Response => {
9+
await new Promise((resolve) => {
10+
setTimeout(resolve, ms);
11+
});
12+
return {
13+
result: ms
14+
};
15+
};
16+
17+
export default main;
Lines changed: 369 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,369 @@
1+
{
2+
"author": "collin",
3+
"version": "4817",
4+
"name": "流程暂停",
5+
"avatar": "core/workflow/template/sleep",
6+
"intro": "让工作流暂停指定时间后运行",
7+
"showStatus": true,
8+
"weight": 10,
9+
10+
"isTool": true,
11+
"templateType": "tools",
12+
13+
"workflow": {
14+
"nodes": [
15+
{
16+
"nodeId": "pluginInput",
17+
"name": "workflow:template.plugin_start",
18+
"intro": "workflow:intro_plugin_input",
19+
"avatar": "core/workflow/template/workflowStart",
20+
"flowNodeType": "pluginInput",
21+
"showStatus": false,
22+
"position": {
23+
"x": 616.4226348688949,
24+
"y": -165.05298493910115
25+
},
26+
"version": "481",
27+
"inputs": [
28+
{
29+
"renderTypeList": [
30+
"numberInput",
31+
"reference"
32+
],
33+
"selectedTypeIndex": 0,
34+
"valueType": "number",
35+
"canEdit": true,
36+
"key": "ms",
37+
"label": "ms",
38+
"description": "需要暂停的时间,毫秒",
39+
"defaultValue": 1000,
40+
"list": [
41+
{
42+
"label": "",
43+
"value": ""
44+
}
45+
],
46+
"maxFiles": 5,
47+
"canSelectFile": true,
48+
"canSelectImg": true,
49+
"required": true,
50+
"toolDescription": "需要暂停的时间,毫秒",
51+
"max": 999999999999,
52+
"min": 1
53+
}
54+
],
55+
"outputs": [
56+
{
57+
"id": "ms",
58+
"valueType": "number",
59+
"key": "ms",
60+
"label": "ms",
61+
"type": "hidden"
62+
}
63+
]
64+
},
65+
{
66+
"nodeId": "pluginOutput",
67+
"name": "common:core.module.template.self_output",
68+
"intro": "workflow:intro_custom_plugin_output",
69+
"avatar": "core/workflow/template/pluginOutput",
70+
"flowNodeType": "pluginOutput",
71+
"showStatus": false,
72+
"position": {
73+
"x": 1925.5772573010433,
74+
"y": -131.55298493910115
75+
},
76+
"version": "481",
77+
"inputs": [
78+
{
79+
"renderTypeList": [
80+
"reference"
81+
],
82+
"valueType": "any",
83+
"canEdit": true,
84+
"key": "result",
85+
"label": "result",
86+
"isToolOutput": true,
87+
"description": "",
88+
"required": true,
89+
"value": [
90+
"zCJC6zw7c14i",
91+
"httpRawResponse"
92+
]
93+
}
94+
],
95+
"outputs": []
96+
},
97+
{
98+
"nodeId": "pluginConfig",
99+
"name": "common:core.module.template.system_config",
100+
"intro": "",
101+
"avatar": "core/workflow/template/systemConfig",
102+
"flowNodeType": "pluginConfig",
103+
"position": {
104+
"x": 184.66337662472682,
105+
"y": -216.05298493910115
106+
},
107+
"version": "4811",
108+
"inputs": [],
109+
"outputs": []
110+
},
111+
{
112+
"nodeId": "zCJC6zw7c14i",
113+
"name": "HTTP 请求",
114+
"intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)",
115+
"avatar": "core/workflow/template/httpRequest",
116+
"flowNodeType": "httpRequest468",
117+
"showStatus": true,
118+
"position": {
119+
"x": 1152.535395637613,
120+
"y": -433.21496011686054
121+
},
122+
"version": "481",
123+
"inputs": [
124+
{
125+
"key": "system_addInputParam",
126+
"renderTypeList": [
127+
"addInputParam"
128+
],
129+
"valueType": "dynamic",
130+
"label": "",
131+
"required": false,
132+
"description": "common:core.module.input.description.HTTP Dynamic Input",
133+
"customInputConfig": {
134+
"selectValueTypeList": [
135+
"string",
136+
"number",
137+
"boolean",
138+
"object",
139+
"arrayString",
140+
"arrayNumber",
141+
"arrayBoolean",
142+
"arrayObject",
143+
"arrayAny",
144+
"any",
145+
"chatHistory",
146+
"datasetQuote",
147+
"dynamic",
148+
"selectApp",
149+
"selectDataset"
150+
],
151+
"showDescription": false,
152+
"showDefaultValue": true
153+
},
154+
"valueDesc": "",
155+
"debugLabel": "",
156+
"toolDescription": ""
157+
},
158+
{
159+
"key": "system_httpMethod",
160+
"renderTypeList": [
161+
"custom"
162+
],
163+
"valueType": "string",
164+
"label": "",
165+
"value": "POST",
166+
"required": true,
167+
"valueDesc": "",
168+
"description": "",
169+
"debugLabel": "",
170+
"toolDescription": ""
171+
},
172+
{
173+
"key": "system_httpTimeout",
174+
"renderTypeList": [
175+
"custom"
176+
],
177+
"valueType": "number",
178+
"label": "",
179+
"value": 30,
180+
"min": 5,
181+
"max": 600,
182+
"required": true,
183+
"valueDesc": "",
184+
"description": "",
185+
"debugLabel": "",
186+
"toolDescription": ""
187+
},
188+
{
189+
"key": "system_httpReqUrl",
190+
"renderTypeList": [
191+
"hidden"
192+
],
193+
"valueType": "string",
194+
"label": "",
195+
"description": "common:core.module.input.description.Http Request Url",
196+
"placeholder": "https://api.ai.com/getInventory",
197+
"required": false,
198+
"value": "sleep",
199+
"valueDesc": "",
200+
"debugLabel": "",
201+
"toolDescription": ""
202+
},
203+
{
204+
"key": "system_httpHeader",
205+
"renderTypeList": [
206+
"custom"
207+
],
208+
"valueType": "any",
209+
"value": [],
210+
"label": "",
211+
"description": "common:core.module.input.description.Http Request Header",
212+
"placeholder": "common:core.module.input.description.Http Request Header",
213+
"required": false,
214+
"valueDesc": "",
215+
"debugLabel": "",
216+
"toolDescription": ""
217+
},
218+
{
219+
"key": "system_httpParams",
220+
"renderTypeList": [
221+
"hidden"
222+
],
223+
"valueType": "any",
224+
"value": [],
225+
"label": "",
226+
"required": false,
227+
"valueDesc": "",
228+
"description": "",
229+
"debugLabel": "",
230+
"toolDescription": ""
231+
},
232+
{
233+
"key": "system_httpJsonBody",
234+
"renderTypeList": [
235+
"hidden"
236+
],
237+
"valueType": "any",
238+
"value": "{\n\"ms\": {{$pluginInput.ms$}}\n}",
239+
"label": "",
240+
"required": false,
241+
"valueDesc": "",
242+
"description": "",
243+
"debugLabel": "",
244+
"toolDescription": ""
245+
},
246+
{
247+
"key": "system_httpFormBody",
248+
"renderTypeList": [
249+
"hidden"
250+
],
251+
"valueType": "any",
252+
"value": [],
253+
"label": "",
254+
"required": false,
255+
"valueDesc": "",
256+
"description": "",
257+
"debugLabel": "",
258+
"toolDescription": ""
259+
},
260+
{
261+
"key": "system_httpContentType",
262+
"renderTypeList": [
263+
"hidden"
264+
],
265+
"valueType": "string",
266+
"value": "json",
267+
"label": "",
268+
"required": false,
269+
"valueDesc": "",
270+
"description": "",
271+
"debugLabel": "",
272+
"toolDescription": ""
273+
}
274+
],
275+
"outputs": [
276+
{
277+
"id": "error",
278+
"key": "error",
279+
"label": "workflow:request_error",
280+
"description": "HTTP请求错误信息,成功时返回空",
281+
"valueType": "object",
282+
"type": "static"
283+
},
284+
{
285+
"id": "httpRawResponse",
286+
"key": "httpRawResponse",
287+
"required": true,
288+
"label": "workflow:raw_response",
289+
"description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
290+
"valueType": "any",
291+
"type": "static"
292+
},
293+
{
294+
"id": "system_addOutputParam",
295+
"key": "system_addOutputParam",
296+
"type": "dynamic",
297+
"valueType": "dynamic",
298+
"label": "输出字段提取",
299+
"customFieldConfig": {
300+
"selectValueTypeList": [
301+
"string",
302+
"number",
303+
"boolean",
304+
"object",
305+
"arrayString",
306+
"arrayNumber",
307+
"arrayBoolean",
308+
"arrayObject",
309+
"arrayAny",
310+
"any",
311+
"chatHistory",
312+
"datasetQuote",
313+
"dynamic",
314+
"selectApp",
315+
"selectDataset"
316+
],
317+
"showDescription": false,
318+
"showDefaultValue": false
319+
},
320+
"description": "可以通过 JSONPath 语法来提取响应值中的指定字段",
321+
"valueDesc": ""
322+
}
323+
]
324+
}
325+
],
326+
"edges": [
327+
{
328+
"source": "pluginInput",
329+
"target": "zCJC6zw7c14i",
330+
"sourceHandle": "pluginInput-source-right",
331+
"targetHandle": "zCJC6zw7c14i-target-left"
332+
},
333+
{
334+
"source": "zCJC6zw7c14i",
335+
"target": "pluginOutput",
336+
"sourceHandle": "zCJC6zw7c14i-source-right",
337+
"targetHandle": "pluginOutput-target-left"
338+
}
339+
],
340+
"chatConfig": {
341+
"welcomeText": "",
342+
"variables": [],
343+
"questionGuide": {
344+
"open": false,
345+
"model": "gpt-4o-mini",
346+
"customPrompt": "You are an AI assistant tasked with predicting the user's next question based on the conversation history. Your goal is to generate 3 potential questions that will guide the user to continue the conversation. When generating these questions, adhere to the following rules:\n\n1. Use the same language as the user's last question in the conversation history.\n2. Keep each question under 20 characters in length.\n\nAnalyze the conversation history provided to you and use it as context to generate relevant and engaging follow-up questions. Your predictions should be logical extensions of the current topic or related areas that the user might be interested in exploring further.\n\nRemember to maintain consistency in tone and style with the existing conversation while providing diverse options for the user to choose from. Your goal is to keep the conversation flowing naturally and help the user delve deeper into the subject matter or explore related topics."
347+
},
348+
"ttsConfig": {
349+
"type": "web"
350+
},
351+
"whisperConfig": {
352+
"open": false,
353+
"autoSend": false,
354+
"autoTTSResponse": false
355+
},
356+
"chatInputGuide": {
357+
"open": false,
358+
"textList": [],
359+
"customUrl": ""
360+
},
361+
"instruction": "",
362+
"autoExecute": {
363+
"open": false,
364+
"defaultPrompt": ""
365+
},
366+
"_id": "6784ba2c227f92f6c723ead0"
367+
}
368+
}
369+
}

0 commit comments

Comments
 (0)