Skip to content

Commit

Permalink
修改了文档和代码部分无搜索的结果的反馈
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiangween committed Jan 2, 2025
1 parent 46fcfa8 commit a9055fd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 179 deletions.
14 changes: 5 additions & 9 deletions docSite/content/zh-cn/docs/guide/plugins/searxng_plugin_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,11 @@ default_doi_resolver: 'oadoi.org'

```Bash
{
"result": "未找到相关搜索结果,可能原因:
1. 搜索引擎未返回结果
2. 搜索请求超时
3. 搜索内容过于专业或生僻
建议:
1. 尝试使用不同的关键词
2. 确认搜索服务是否正常
3. 稍后重试"
"result": "[]",
"error": {
"message": "No search results",
"code": 500
}
}
```

Expand Down
10 changes: 10 additions & 0 deletions packages/plugins/src/searchXNG/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ const main = async (props: Props, retry = 3): Response => {
});
});

if (results.length === 0) {
return {
result: JSON.stringify([]),
error: {
message: 'No search results',
code: 500
}
};
}

return {
result: JSON.stringify(results.slice(0, 10))
};
Expand Down
175 changes: 5 additions & 170 deletions packages/plugins/src/searchXNG/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
"maxFiles": 5,
"canSelectFile": true,
"canSelectImg": true,
"required": true,
"toolDescription": "部署的searXNG服务的链接"
"required": true
}
],
"outputs": [
Expand Down Expand Up @@ -84,8 +83,8 @@
"flowNodeType": "pluginOutput",
"showStatus": false,
"position": {
"x": 2552.194334325031,
"y": 26.438723435001748
"x": 1763.7518709731714,
"y": -55.56127656499825
},
"version": "481",
"inputs": [
Expand All @@ -96,7 +95,7 @@
"key": "result",
"label": "result",
"description": " 检索结果",
"value": ["sKOiypglFFCu", "qLUQfhG0ILRX"]
"value": ["hjnVuJAOwyXV", "lEyy5QqyIBrK"]
},
{
"renderTypeList": ["reference"],
Expand Down Expand Up @@ -370,164 +369,6 @@
"version": "4811",
"inputs": [],
"outputs": []
},
{
"nodeId": "sKOiypglFFCu",
"name": "代码运行",
"intro": "执行一段简单的脚本代码,通常用于进行复杂的数据处理。",
"avatar": "core/workflow/template/codeRun",
"flowNodeType": "code",
"showStatus": true,
"position": {
"x": 1947.3672830609507,
"y": -214.56127656499825
},
"version": "482",
"inputs": [
{
"key": "system_addInputParam",
"renderTypeList": ["addInputParam"],
"valueType": "dynamic",
"label": "",
"required": false,
"description": "workflow:these_variables_will_be_input_parameters_for_code_execution",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"arrayAny",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
},
"valueDesc": "",
"debugLabel": "",
"toolDescription": ""
},
{
"key": "codeType",
"renderTypeList": ["hidden"],
"label": "",
"value": "js",
"valueDesc": "",
"description": "",
"debugLabel": "",
"toolDescription": ""
},
{
"key": "code",
"renderTypeList": ["custom"],
"label": "",
"value": "function main({data1}){\n // 检查结果是否为空\n if(!data1 || !data1.results || data1.results.length === 0) {\n return {\n result: \"未找到相关搜索结果,可能原因:\\n1. 搜索引擎未返回结果\\n2. 搜索请求超时\\n3. 搜索内容过于专业或生僻\\n\\n建议:\\n1. 尝试使用不同的关键词\\n2. 确认搜索服务是否正常\\n3. 稍后重试\"\n }\n }\n \n // 返回正常结果\n return {\n result: data1\n }\n}",
"valueDesc": "",
"description": "",
"debugLabel": "",
"toolDescription": ""
},
{
"renderTypeList": ["reference"],
"valueType": "string",
"canEdit": true,
"key": "data1",
"label": "data1",
"customInputConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"arrayAny",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": true
},
"required": true,
"value": ["hjnVuJAOwyXV", "lEyy5QqyIBrK"],
"valueDesc": "",
"description": "",
"debugLabel": "",
"toolDescription": ""
}
],
"outputs": [
{
"id": "system_rawResponse",
"key": "system_rawResponse",
"label": "workflow:full_response_data",
"valueType": "object",
"type": "static",
"description": ""
},
{
"id": "error",
"key": "error",
"label": "workflow:execution_error",
"description": "代码运行错误信息,成功时返回空",
"valueType": "object",
"type": "static"
},
{
"id": "system_addOutputParam",
"key": "system_addOutputParam",
"type": "dynamic",
"valueType": "dynamic",
"label": "",
"customFieldConfig": {
"selectValueTypeList": [
"string",
"number",
"boolean",
"object",
"arrayString",
"arrayNumber",
"arrayBoolean",
"arrayObject",
"arrayAny",
"any",
"chatHistory",
"datasetQuote",
"dynamic",
"selectApp",
"selectDataset"
],
"showDescription": false,
"showDefaultValue": false
},
"description": "将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key",
"valueDesc": ""
},
{
"id": "qLUQfhG0ILRX",
"type": "dynamic",
"key": "result",
"valueType": "string",
"label": "result",
"valueDesc": "",
"description": ""
}
]
}
],
"edges": [
Expand All @@ -539,14 +380,8 @@
},
{
"source": "hjnVuJAOwyXV",
"target": "sKOiypglFFCu",
"sourceHandle": "hjnVuJAOwyXV-source-right",
"targetHandle": "sKOiypglFFCu-target-left"
},
{
"source": "sKOiypglFFCu",
"target": "pluginOutput",
"sourceHandle": "sKOiypglFFCu-source-right",
"sourceHandle": "hjnVuJAOwyXV-source-right",
"targetHandle": "pluginOutput-target-left"
}
],
Expand Down

0 comments on commit a9055fd

Please sign in to comment.