mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
feat: add http node timeout (#2465)
* fix $ in replacement string misinterpreted as regex special character * add http timeout * delete console log
This commit is contained in:
@@ -105,6 +105,7 @@ export enum NodeInputKeyEnum {
|
||||
httpMethod = 'system_httpMethod',
|
||||
httpParams = 'system_httpParams',
|
||||
httpJsonBody = 'system_httpJsonBody',
|
||||
httpTimeout = 'system_httpTimeout',
|
||||
abandon_httpUrl = 'url',
|
||||
|
||||
// app
|
||||
|
@@ -44,6 +44,16 @@ export const HttpNode468: FlowNodeTemplateType = {
|
||||
value: 'POST',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
key: NodeInputKeyEnum.httpTimeout,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.custom],
|
||||
valueType: WorkflowIOValueTypeEnum.number,
|
||||
label: '',
|
||||
value: 120,
|
||||
min: 30,
|
||||
max: 600,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
key: NodeInputKeyEnum.httpReqUrl,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden],
|
||||
|
@@ -57,6 +57,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
|
||||
system_httpHeader: httpHeader,
|
||||
system_httpParams: httpParams = [],
|
||||
system_httpJsonBody: httpJsonBody,
|
||||
system_httpTimeout: httpTimeout,
|
||||
[NodeInputKeyEnum.addInputParam]: dynamicInput,
|
||||
...body
|
||||
}
|
||||
@@ -143,7 +144,8 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
|
||||
url: httpReqUrl,
|
||||
headers,
|
||||
body: requestBody,
|
||||
params
|
||||
params,
|
||||
timeout: httpTimeout
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -199,13 +201,15 @@ async function fetchData({
|
||||
url,
|
||||
headers,
|
||||
body,
|
||||
params
|
||||
params,
|
||||
timeout
|
||||
}: {
|
||||
method: string;
|
||||
url: string;
|
||||
headers: Record<string, any>;
|
||||
body: Record<string, any> | string;
|
||||
params: Record<string, any>;
|
||||
timeout: number;
|
||||
}) {
|
||||
const { data: response } = await axios({
|
||||
method,
|
||||
@@ -215,7 +219,7 @@ async function fetchData({
|
||||
'Content-Type': 'application/json',
|
||||
...headers
|
||||
},
|
||||
timeout: 120000,
|
||||
timeout: timeout * 1000,
|
||||
params: params,
|
||||
data: ['POST', 'PUT', 'PATCH'].includes(method) ? body : undefined
|
||||
});
|
||||
@@ -308,7 +312,7 @@ function replaceVariable(text: string, obj: Record<string, any>) {
|
||||
replacement.startsWith('"') && replacement.endsWith('"')
|
||||
? replacement.slice(1, -1)
|
||||
: replacement;
|
||||
text = text.replace(new RegExp(`{{(${key})}}`, 'g'), unquotedReplacement);
|
||||
text = text.replace(new RegExp(`{{(${key})}}`, 'g'), () => unquotedReplacement);
|
||||
}
|
||||
}
|
||||
return text || '';
|
||||
|
@@ -617,7 +617,8 @@
|
||||
"success": "Start syncing"
|
||||
}
|
||||
},
|
||||
"training": {}
|
||||
"training": {
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"Auxiliary Data": "Auxiliary data",
|
||||
@@ -795,6 +796,7 @@
|
||||
"Field Name": "Field name",
|
||||
"Http request props": "Request parameters",
|
||||
"Http request settings": "Request settings",
|
||||
"Http timeout": "Timeout",
|
||||
"Input Type": "Input type",
|
||||
"Laf sync params": "Synchronize parameters",
|
||||
"Max Length": "Maximum length",
|
||||
|
@@ -617,7 +617,8 @@
|
||||
"success": "开始同步"
|
||||
}
|
||||
},
|
||||
"training": {}
|
||||
"training": {
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"Auxiliary Data": "辅助数据",
|
||||
@@ -795,6 +796,7 @@
|
||||
"Field Name": "字段名",
|
||||
"Http request props": "请求参数",
|
||||
"Http request settings": "请求配置",
|
||||
"Http timeout": "超时时长",
|
||||
"Input Type": "输入类型",
|
||||
"Laf sync params": "同步参数",
|
||||
"Max Length": "最大长度",
|
||||
@@ -993,7 +995,6 @@
|
||||
"Edit Folder": "编辑文件夹",
|
||||
"Edit Info": "编辑信息",
|
||||
"Export": "导出",
|
||||
"dataset_name": "知识库名称",
|
||||
"Export Dataset Limit Error": "导出数据失败",
|
||||
"Folder Name": "输入文件夹名称",
|
||||
"Insert Data": "插入",
|
||||
@@ -1031,6 +1032,7 @@
|
||||
},
|
||||
"input is empty": "数据内容不能为空 "
|
||||
},
|
||||
"dataset_name": "知识库名称",
|
||||
"deleteFolderTips": "确认删除该文件夹及其包含的所有知识库?删除后数据无法恢复,请确认!",
|
||||
"test": {
|
||||
"noResult": "搜索结果为空"
|
||||
|
Reference in New Issue
Block a user