mirror of
https://github.com/labring/FastGPT.git
synced 2026-02-28 01:02:28 +08:00
V4.8.16 dev (#3431)
* feat: add feishu & yuque dataset (#3379) * feat: add feishu & yuque dataset * fix ts * fix ts * move type position * fix * fix: merge interface * fix * feat: dingtalk sso support (#3408) * fix: optional sso state * feat: dingtalk bot * feat: dingtalk sso login * chore: move i18n to user namespace * feat: dingtalk bot integration (#3415) * feat: dingtalk bot integration * docs: config dingtalk bot * feat:sear XNG服务 (#3413) * feat:sear XNG服务 * 补充了courseUrl * 添加了官方文档 * 错误时返回情况修正了一下 * Tracks (#3420) * feat: node intro * feat: add domain track * dingding sso login * perf: api dataset code and add doc * feat: tracks * feat: searXNG plugins * fix: ts * feat: delete node tracks (#3423) * fix: dingtalk bot GET verification (#3424) * 4.8.16 test: fix: plugin inputs render;fix: ui offset (#3426) * fix: ui offset * perf: dingding talk * fix: plugin inputs render * feat: menu all folder (#3429) * fix: recall code --------- Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: a.e. <49438478+I-Info@users.noreply.github.com> Co-authored-by: Jiangween <145003935+Jiangween@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"@types/pg": "^8.6.6",
|
||||
"axios": "^1.5.1",
|
||||
"duck-duck-scrape": "^2.2.5",
|
||||
|
||||
@@ -27,7 +27,8 @@ const packagePluginList = [
|
||||
'wiki',
|
||||
'databaseConnection',
|
||||
'Doc2X',
|
||||
'Doc2X/PDF2text'
|
||||
'Doc2X/PDF2text',
|
||||
'searchXNG'
|
||||
];
|
||||
|
||||
export const list = [...staticPluginList, ...packagePluginList];
|
||||
|
||||
66
packages/plugins/src/searchXNG/index.ts
Normal file
66
packages/plugins/src/searchXNG/index.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { delay } from '@fastgpt/global/common/system/utils';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { i18nT } from '../../../web/i18n/utils';
|
||||
|
||||
type Props = {
|
||||
query: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
interface SearchResult {
|
||||
title: string;
|
||||
link: string;
|
||||
snippet: string;
|
||||
}
|
||||
|
||||
type Response = Promise<{
|
||||
result: string;
|
||||
error?: Record<string, any>;
|
||||
}>;
|
||||
|
||||
const main = async (props: Props, retry = 3): Response => {
|
||||
const { query, url } = props;
|
||||
|
||||
if (!query) {
|
||||
return Promise.reject(i18nT('chat:not_query'));
|
||||
}
|
||||
|
||||
if (!url) {
|
||||
return Promise.reject('Can not find url');
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${url}?q=${encodeURIComponent(query)}&language=auto`);
|
||||
const html = await response.text();
|
||||
const $ = cheerio.load(html, {
|
||||
xml: false,
|
||||
decodeEntities: true
|
||||
});
|
||||
|
||||
const results: SearchResult[] = [];
|
||||
|
||||
$('.result').each((_: number, element: cheerio.Element) => {
|
||||
const $element = $(element);
|
||||
results.push({
|
||||
title: $element.find('h3').text().trim(),
|
||||
link: $element.find('a').first().attr('href') || '',
|
||||
snippet: $element.find('.content').text().trim()
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
result: JSON.stringify(results.slice(0, 10))
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
if (retry <= 0) {
|
||||
console.log('Search XNG error', { error });
|
||||
return Promise.reject('Failed to fetch data from Search XNG');
|
||||
}
|
||||
|
||||
await delay(Math.random() * 2000);
|
||||
return main(props, retry - 1);
|
||||
}
|
||||
};
|
||||
|
||||
export default main;
|
||||
414
packages/plugins/src/searchXNG/template.json
Normal file
414
packages/plugins/src/searchXNG/template.json
Normal file
@@ -0,0 +1,414 @@
|
||||
{
|
||||
"author": "",
|
||||
"version": "4816",
|
||||
"name": "Search XNG 搜索",
|
||||
"avatar": "core/workflow/template/searxng",
|
||||
"intro": "使用 Search XNG 服务进行搜索。",
|
||||
"courseUrl": "/docs/guide/plugins/searxng_plugin_guide/",
|
||||
"showStatus": true,
|
||||
"weight": 10,
|
||||
|
||||
"isTool": true,
|
||||
"templateType": "search",
|
||||
|
||||
"workflow": {
|
||||
"nodes": [
|
||||
{
|
||||
"nodeId": "pluginInput",
|
||||
"name": "插件开始",
|
||||
"intro": "可以配置插件需要哪些输入,利用这些输入来运行插件",
|
||||
"avatar": "core/workflow/template/workflowStart",
|
||||
"flowNodeType": "pluginInput",
|
||||
"showStatus": false,
|
||||
"position": {
|
||||
"x": 482.8986144681427,
|
||||
"y": -77.56127656499825
|
||||
},
|
||||
"version": "481",
|
||||
"inputs": [
|
||||
{
|
||||
"renderTypeList": ["input", "reference"],
|
||||
"selectedTypeIndex": 0,
|
||||
"valueType": "string",
|
||||
"canEdit": true,
|
||||
"key": "query",
|
||||
"label": "query",
|
||||
"description": "检索词",
|
||||
"required": true,
|
||||
"toolDescription": "检索词"
|
||||
},
|
||||
{
|
||||
"renderTypeList": ["input", "reference"],
|
||||
"selectedTypeIndex": 0,
|
||||
"valueType": "string",
|
||||
"canEdit": true,
|
||||
"key": "url",
|
||||
"label": "url",
|
||||
"description": "部署的searXNG服务的链接",
|
||||
"defaultValue": "",
|
||||
"list": [
|
||||
{
|
||||
"label": "",
|
||||
"value": ""
|
||||
}
|
||||
],
|
||||
"maxFiles": 5,
|
||||
"canSelectFile": true,
|
||||
"canSelectImg": true,
|
||||
"required": true,
|
||||
"toolDescription": "部署的searXNG服务的链接"
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"id": "query",
|
||||
"valueType": "string",
|
||||
"key": "query",
|
||||
"label": "query",
|
||||
"type": "hidden"
|
||||
},
|
||||
{
|
||||
"id": "url",
|
||||
"valueType": "string",
|
||||
"key": "url",
|
||||
"label": "url",
|
||||
"type": "hidden"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "pluginOutput",
|
||||
"name": "插件输出",
|
||||
"intro": "自定义配置外部输出,使用插件时,仅暴露自定义配置的输出",
|
||||
"avatar": "core/workflow/template/pluginOutput",
|
||||
"flowNodeType": "pluginOutput",
|
||||
"showStatus": false,
|
||||
"position": {
|
||||
"x": 1763.7518709731714,
|
||||
"y": -55.56127656499825
|
||||
},
|
||||
"version": "481",
|
||||
"inputs": [
|
||||
{
|
||||
"renderTypeList": ["reference"],
|
||||
"valueType": "string",
|
||||
"canEdit": true,
|
||||
"key": "result",
|
||||
"label": "result",
|
||||
"description": " 检索结果",
|
||||
"value": ["hjnVuJAOwyXV", "lEyy5QqyIBrK"]
|
||||
},
|
||||
{
|
||||
"renderTypeList": ["reference"],
|
||||
"valueType": "object",
|
||||
"canEdit": true,
|
||||
"key": "error",
|
||||
"label": "error",
|
||||
"isToolOutput": true,
|
||||
"description": "请求错误",
|
||||
"required": true,
|
||||
"value": ["hjnVuJAOwyXV", "error"]
|
||||
}
|
||||
],
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"nodeId": "hjnVuJAOwyXV",
|
||||
"name": "HTTP 请求",
|
||||
"intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)",
|
||||
"avatar": "core/workflow/template/httpRequest",
|
||||
"flowNodeType": "httpRequest468",
|
||||
"showStatus": true,
|
||||
"position": {
|
||||
"x": 1054.6774638324207,
|
||||
"y": -403.06127656499825
|
||||
},
|
||||
"version": "481",
|
||||
"inputs": [
|
||||
{
|
||||
"key": "system_addInputParam",
|
||||
"renderTypeList": ["addInputParam"],
|
||||
"valueType": "dynamic",
|
||||
"label": "",
|
||||
"required": false,
|
||||
"description": "common:core.module.input.description.HTTP Dynamic Input",
|
||||
"customInputConfig": {
|
||||
"selectValueTypeList": [
|
||||
"string",
|
||||
"number",
|
||||
"boolean",
|
||||
"object",
|
||||
"arrayString",
|
||||
"arrayNumber",
|
||||
"arrayBoolean",
|
||||
"arrayObject",
|
||||
"arrayAny",
|
||||
"any",
|
||||
"chatHistory",
|
||||
"datasetQuote",
|
||||
"dynamic",
|
||||
"selectApp",
|
||||
"selectDataset"
|
||||
],
|
||||
"showDescription": false,
|
||||
"showDefaultValue": true
|
||||
},
|
||||
"debugLabel": "",
|
||||
"toolDescription": ""
|
||||
},
|
||||
{
|
||||
"key": "system_httpMethod",
|
||||
"renderTypeList": ["custom"],
|
||||
"valueType": "string",
|
||||
"label": "",
|
||||
"value": "POST",
|
||||
"required": true,
|
||||
"debugLabel": "",
|
||||
"toolDescription": ""
|
||||
},
|
||||
{
|
||||
"key": "system_httpTimeout",
|
||||
"renderTypeList": ["custom"],
|
||||
"valueType": "number",
|
||||
"label": "",
|
||||
"value": 30,
|
||||
"min": 5,
|
||||
"max": 600,
|
||||
"required": true,
|
||||
"debugLabel": "",
|
||||
"toolDescription": ""
|
||||
},
|
||||
{
|
||||
"key": "system_httpReqUrl",
|
||||
"renderTypeList": ["hidden"],
|
||||
"valueType": "string",
|
||||
"label": "",
|
||||
"description": "common:core.module.input.description.Http Request Url",
|
||||
"placeholder": "https://api.ai.com/getInventory",
|
||||
"required": false,
|
||||
"value": "searchXNG",
|
||||
"debugLabel": "",
|
||||
"toolDescription": ""
|
||||
},
|
||||
{
|
||||
"key": "system_httpHeader",
|
||||
"renderTypeList": ["custom"],
|
||||
"valueType": "any",
|
||||
"value": [],
|
||||
"label": "",
|
||||
"description": "common:core.module.input.description.Http Request Header",
|
||||
"placeholder": "common:core.module.input.description.Http Request Header",
|
||||
"required": false,
|
||||
"debugLabel": "",
|
||||
"toolDescription": ""
|
||||
},
|
||||
{
|
||||
"key": "system_httpParams",
|
||||
"renderTypeList": ["hidden"],
|
||||
"valueType": "any",
|
||||
"value": [],
|
||||
"label": "",
|
||||
"required": false,
|
||||
"debugLabel": "",
|
||||
"toolDescription": ""
|
||||
},
|
||||
{
|
||||
"key": "system_httpJsonBody",
|
||||
"renderTypeList": ["hidden"],
|
||||
"valueType": "any",
|
||||
"value": "{\n \"query\": \"{{query}}\",\n \"url\": \"{{url}}\"\n}",
|
||||
"label": "",
|
||||
"required": false,
|
||||
"debugLabel": "",
|
||||
"toolDescription": ""
|
||||
},
|
||||
{
|
||||
"key": "system_httpFormBody",
|
||||
"renderTypeList": ["hidden"],
|
||||
"valueType": "any",
|
||||
"value": [],
|
||||
"label": "",
|
||||
"required": false,
|
||||
"debugLabel": "",
|
||||
"toolDescription": ""
|
||||
},
|
||||
{
|
||||
"key": "system_httpContentType",
|
||||
"renderTypeList": ["hidden"],
|
||||
"valueType": "string",
|
||||
"value": "json",
|
||||
"label": "",
|
||||
"required": false,
|
||||
"debugLabel": "",
|
||||
"toolDescription": ""
|
||||
},
|
||||
{
|
||||
"renderTypeList": ["reference"],
|
||||
"valueType": "string",
|
||||
"canEdit": true,
|
||||
"key": "query",
|
||||
"label": "query",
|
||||
"customInputConfig": {
|
||||
"selectValueTypeList": [
|
||||
"string",
|
||||
"number",
|
||||
"boolean",
|
||||
"object",
|
||||
"arrayString",
|
||||
"arrayNumber",
|
||||
"arrayBoolean",
|
||||
"arrayObject",
|
||||
"arrayAny",
|
||||
"any",
|
||||
"chatHistory",
|
||||
"datasetQuote",
|
||||
"dynamic",
|
||||
"selectApp",
|
||||
"selectDataset"
|
||||
],
|
||||
"showDescription": false,
|
||||
"showDefaultValue": true
|
||||
},
|
||||
"required": true,
|
||||
"value": ["pluginInput", "query"]
|
||||
},
|
||||
{
|
||||
"renderTypeList": ["reference"],
|
||||
"valueType": "string",
|
||||
"canEdit": true,
|
||||
"key": "url",
|
||||
"label": "url",
|
||||
"customInputConfig": {
|
||||
"selectValueTypeList": [
|
||||
"string",
|
||||
"number",
|
||||
"boolean",
|
||||
"object",
|
||||
"arrayString",
|
||||
"arrayNumber",
|
||||
"arrayBoolean",
|
||||
"arrayObject",
|
||||
"arrayAny",
|
||||
"any",
|
||||
"chatHistory",
|
||||
"datasetQuote",
|
||||
"dynamic",
|
||||
"selectApp",
|
||||
"selectDataset"
|
||||
],
|
||||
"showDescription": false,
|
||||
"showDefaultValue": true
|
||||
},
|
||||
"required": true,
|
||||
"value": ["pluginInput", "url"]
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"id": "error",
|
||||
"key": "error",
|
||||
"label": "workflow:request_error",
|
||||
"description": "HTTP请求错误信息,成功时返回空",
|
||||
"valueType": "object",
|
||||
"type": "static"
|
||||
},
|
||||
{
|
||||
"id": "httpRawResponse",
|
||||
"key": "httpRawResponse",
|
||||
"required": true,
|
||||
"label": "workflow:raw_response",
|
||||
"description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
|
||||
"valueType": "any",
|
||||
"type": "static"
|
||||
},
|
||||
{
|
||||
"id": "system_addOutputParam",
|
||||
"key": "system_addOutputParam",
|
||||
"type": "dynamic",
|
||||
"valueType": "dynamic",
|
||||
"label": "",
|
||||
"customFieldConfig": {
|
||||
"selectValueTypeList": [
|
||||
"string",
|
||||
"number",
|
||||
"boolean",
|
||||
"object",
|
||||
"arrayString",
|
||||
"arrayNumber",
|
||||
"arrayBoolean",
|
||||
"arrayObject",
|
||||
"any",
|
||||
"chatHistory",
|
||||
"datasetQuote",
|
||||
"dynamic",
|
||||
"selectApp",
|
||||
"selectDataset"
|
||||
],
|
||||
"showDescription": false,
|
||||
"showDefaultValue": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "lEyy5QqyIBrK",
|
||||
"valueType": "string",
|
||||
"type": "dynamic",
|
||||
"key": "result",
|
||||
"label": "result"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nodeId": "f1mRh1D85H2D",
|
||||
"name": "系统配置",
|
||||
"intro": "",
|
||||
"avatar": "core/workflow/template/systemConfig",
|
||||
"flowNodeType": "pluginConfig",
|
||||
"position": {
|
||||
"x": -28.511358745511643,
|
||||
"y": -103.56127656499825
|
||||
},
|
||||
"version": "4811",
|
||||
"inputs": [],
|
||||
"outputs": []
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"source": "pluginInput",
|
||||
"target": "hjnVuJAOwyXV",
|
||||
"sourceHandle": "pluginInput-source-right",
|
||||
"targetHandle": "hjnVuJAOwyXV-target-left"
|
||||
},
|
||||
{
|
||||
"source": "hjnVuJAOwyXV",
|
||||
"target": "pluginOutput",
|
||||
"sourceHandle": "hjnVuJAOwyXV-source-right",
|
||||
"targetHandle": "pluginOutput-target-left"
|
||||
}
|
||||
],
|
||||
"chatConfig": {
|
||||
"welcomeText": "",
|
||||
"variables": [],
|
||||
"questionGuide": false,
|
||||
"ttsConfig": {
|
||||
"type": "web"
|
||||
},
|
||||
"whisperConfig": {
|
||||
"open": false,
|
||||
"autoSend": false,
|
||||
"autoTTSResponse": false
|
||||
},
|
||||
"chatInputGuide": {
|
||||
"open": false,
|
||||
"textList": [],
|
||||
"customUrl": ""
|
||||
},
|
||||
"instruction": "",
|
||||
"autoExecute": {
|
||||
"open": false,
|
||||
"defaultPrompt": ""
|
||||
},
|
||||
"_id": "67611a5eed7efa452a6e50c5"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user