Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ai
/
ai-workflow
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e146cb9a
authored
Jun 15, 2026
by
sunqi02
Committed by
胡悦
Jul 06, 2026
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 更新知识检索脚本,简化超时处理逻辑,增加超时时间至120秒
1 parent
b6b50ec6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
28 deletions
workspace/agent-admin/backend/skills/query-knowledge/SKILL.md
workspace/agent-admin/backend/skills/query-knowledge/scripts/query_knowledge.py
workspace/agent-admin/backend/skills/query-knowledge/SKILL.md
View file @
e146cb9
...
...
@@ -22,11 +22,9 @@ python skills/query-knowledge/scripts/query_knowledge.py "<用户问题原文>"
```
-
将用户问题原文原样传入,不要改写或截断
-
脚本接口响应较慢,已内置超时重试,无需额外处理
-
不要自行查找或构造 QUERY_URL,脚本内部会自动处理
-
查询耗时最多 120 秒,耐心等待结果
## 结果处理
**脚本执行成功**
:stdout 输出检索结果,直接呈现给用户。保留原文中的 Markdown 格式(加粗、换行等)。
**脚本输出以 "❌" 开头**
:说明查询失败,将脚本输出的错误信息直接告诉用户。不要尝试排查原因、不要检查配置文件、不要修改脚本。脚本已自行处理所有错误场景。
-
脚本 stdout 输出检索结果 → 直接呈现给用户
-
脚本输出以 "❌" 开头 → 将错误信息直接告诉用户,不要尝试排查或修改文件
workspace/agent-admin/backend/skills/query-knowledge/scripts/query_knowledge.py
View file @
e146cb9
...
...
@@ -10,7 +10,6 @@ On failure, prints error message to stdout (not stderr) so the agent can relay i
import
json
import
os
import
sys
import
time
from
pathlib
import
Path
import
requests
...
...
@@ -43,28 +42,19 @@ def main():
print
(
"❌当前查询服务不可用,请联系开发人员"
)
sys
.
exit
(
0
)
max_retries
=
2
timeout
=
60
for
attempt
in
range
(
max_retries
):
try
:
resp
=
requests
.
post
(
url
,
json
=
{
"query"
:
query
},
timeout
=
timeout
)
resp
.
raise_for_status
()
data
=
resp
.
json
()
break
except
requests
.
Timeout
:
if
attempt
<
max_retries
-
1
:
timeout
=
90
time
.
sleep
(
2
)
continue
print
(
"❌知识库查询超时,请稍后重试"
)
sys
.
exit
(
0
)
except
requests
.
RequestException
as
e
:
print
(
f
"❌知识库查询失败: {e}"
)
sys
.
exit
(
0
)
except
json
.
JSONDecodeError
:
print
(
"❌知识库返回数据异常,请联系开发人员"
)
sys
.
exit
(
0
)
try
:
resp
=
requests
.
post
(
url
,
json
=
{
"query"
:
query
},
timeout
=
120
)
resp
.
raise_for_status
()
data
=
resp
.
json
()
except
requests
.
Timeout
:
print
(
"❌知识库查询超时,请稍后重试"
)
sys
.
exit
(
0
)
except
requests
.
RequestException
as
e
:
print
(
f
"❌知识库查询失败: {e}"
)
sys
.
exit
(
0
)
except
json
.
JSONDecodeError
:
print
(
"❌知识库返回数据异常,请联系开发人员"
)
sys
.
exit
(
0
)
answers
=
data
.
get
(
"answer"
,
[])
if
not
answers
:
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment