Skip to content

添加 [DeepSeek 网页抓取] 工具(Fetch,配套 #135) - #138

Merged
hao65103940 merged 1 commit into
1Panel-dev:mainfrom
gzzwp:feat/tool-deepseek-fetch-fix
Oct 19, 2026
Merged

hao65103940 merged 1 commit into
1Panel-dev:mainfrom
gzzwp:feat/tool-deepseek-fetch-fix

Conversation

@gzzwp

@gzzwp gzzwp commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

添加 DeepSeek 网页抓取工具(Fetch)

配套 DeepSeek 联网搜索工具(#135):Search 负责检索,Fetch 负责抓正文。

功能

  • 调用 DeepSeek 官方 Fetch API:POST https://api.deepseek.com/v1/tools/fetch
  • 输入 URL,返回页面标题与 Markdown 正文
  • max_chars 控制正文上限(默认 8000),超长自动截断并标注
  • 返回 title / content / markdown / truncated,同时给出 # 标题 + 来源链接 + 正文 的拼装结果
  • 失败统一返回 success=false + 中文 hint,不抛异常

参数

参数 组件类型 必填 说明
api_key 密码框(启动参数) 是 DeepSeek API Key
url string(引用参数) 是 目标网页地址,含 host 的 http/https,≤8192 字符
max_chars int(自定义参数) 否 正文字符上限,默认 8000

错误处理

400/401/402/403/404/429/5xx 分级返回提示。其中 403(被安全策略拒)与 404(无可提取正文)
按业务失败处理,编排中可据此跳过该链接继续,而非中断流程。

推荐编排

开始(question) → DeepSeek 联网搜索(count=5) → 选出最相关 1~2 条 url
              → DeepSeek 网页抓取(max_chars=6000) → 基于正文生成带引用的回答

关于描述长度

初版描述为 156 字符,导入时报 value too long for type character varying(128)
(Tool.desc 在 apps/tools/models/tool.py 中为 CharField(max_length=128))。
已压缩至 89 字符,并重新生成 .tool;生成脚本已加入逐字段长度断言。

验证

  • .tool 通过 RestrictedUnpickler 白名单反序列化自测
  • 逐字段比对 Tool 模型 max_length,无超长字段
  • AST 校验入口 main 位于代码末尾
  • 参数校验与 401 错误分支实测返回结构正确

配套 DeepSeek 联网搜索工具(1Panel-dev#135):Search 负责检索,Fetch 负责抓正文。

- POST https://api.deepseek.com/v1/tools/fetch
- max_chars 控制正文上限(默认 8000),超长截断并标注
- 403/404 等按业务失败处理(success=false + 中文 hint),不抛异常
- 描述压缩至 89 字符,避免 Tool.desc 的 varchar(128) 溢出
@github-actions

Copy link
Copy Markdown

✅ PR 自动校验结果

状态: 校验通过

本次 PR 涉及 1 个工具目录:

🔍 校验: tools/tool_deepseek_fetch

==================================================
✅ 所有校验通过!

@hao65103940
hao65103940 merged commit 0aef884 into 1Panel-dev:main Oct 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants