Skip to main content

amrita_plugin_deepseek

amrita_plugin_deepseek 是 Amrita 框架官方提供的 DeepSeek 模型扩展,用于解析、拦截并安全执行 DeepSeek DSML(DeepSeek Markup Language)工具调用

什么是 DSML?

DSML(DeepSeek Markup Language)是 DeepSeek 模型内部用于描述 Tool Calling(工具调用) 的底层标记语言。当模型需要调用外部工具时,会生成类似下面的内容:

DeepSeek V3/R1

<|DSML|function_calls>
<|DSML|invoke name="webscraper">
<|DSML|parameter name="url">https://example.com</|DSML|parameter>
</|DSML|invoke>
</|DSML|function_calls>

DeepSeek V4

<||DSML||tool_calls>
<||DSML||invoke name="execute_command">
<||DSML||parameter name="command" string="true">uname -a</||DSML||parameter>
</||DSML||invoke>
</||DSML||tool_calls>

DeepSeek V4.1

<||DSML|| calls>
<||DSML|| invoke name="a_plus_b">
<||DSML|| parameter name="a" string="false">1</||DSML|| parameter>
<||DSML|| parameter name="b" string="false">1</||DSML|| parameter>
</||DSML|| invoke>
</||DSML|| calls>

在正常情况下,这些标记会由模型运行时自动解析,最终用户不会看到任何 DSML 内容

然而,在消息链中断、工具调用流程异常、适配器未正确处理 Tool Calling,或直接与模型 API 交互等场景下,DeepSeek 可能会将这些底层标记直接输出给用户,不仅影响对话体验,也无法真正完成工具调用。

amrita_plugin_deepseek 正是为了解决这一问题而设计。

插件会自动识别模型输出中的 DSML 标签,将其解析为工具调用,并在安全校验通过后执行对应工具,最后把执行结果返回给模型继续生成自然语言回复,使整个 Tool Calling 流程恢复正常,对最终用户保持透明。

除了完成 DSML 的解析与执行外,插件还提供了一套完整的安全防护机制,用于检测恶意 DSML、提示注入(Prompt Injection)以及其他潜在风险,保障 AI 对话系统的安全性与可靠性。

✨ 功能特点

DSML 解析

  • 自动识别 DeepSeek 输出的 DSML 标签
  • 解析函数调用及参数
  • 安全执行对应工具
  • 自动将执行结果回写至模型上下文
  • 全流程对最终用户透明

安全防护

  • 双向安全检测(用户输入 / AI 输出)
  • Prompt Injection 防护
  • MinHash 相似度关键词检测
  • 恶意 DSML 标签拦截
  • 实时管理员安全警报

开箱即用

  • 零配置安装
  • 自动注册至 Amrita
  • 自动启用全部安全策略
  • 支持通过 .env 调整安全检测敏感度

快速开始

ambot plugin install amrita_plugin_deepseek

.env 配置项

虽然本插件采用零配置设计,但您可以通过 .env 文件自定义安全检测的敏感度。在项目根目录创建 .env 文件并添加以下配置:

# DeepSeek安全扩展包配置
SECURITY_INVOKE=0.65

配置项说明

  • SECURITY_INVOKE:

    • 类型: 浮点数 (0.0 - 1.0)
    • 默认值: 0.65
    • 说明: 设置安全检测的MinHash相似度阈值。值越高,检测越严格(更少的误报,但可能漏检);值越低,检测越敏感(更多的检测,但可能增加误报)。
    • 建议范围: 0.5 - 0.8
      • 0.5 - 0.6: 低敏感度,适合宽松环境
      • 0.65 - 0.7: 中等敏感度,推荐默认值
      • 0.75 - 0.8: 高敏感度,适合高安全要求环境
  • APPEND_TOOL:

    • 类型: 布尔值 (true/false)
    • 默认值: false
    • 说明: 是否将工具调用结果追加到模型上下文中。
    • 建议: 默认关闭

注意: 修改配置后需要重启应用才能生效。

Release files for amrita_plugin_deepseek 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for amrita_plugin_deepseek 0.1.6
File Size Uploaded
amrita_plugin_deepseek-0.1.6.tar.gz 23.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for amrita_plugin_deepseek 0.1.6
File Interpreter ABI Platform
amrita_plugin_deepseek-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 46.5 kB

Release files / amrita_plugin_deepseek-0.1.6.tar.gz

Download URL amrita_plugin_deepseek-0.1.6.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
15b57032a71b1e39620e5cdc3f61f9003fd6045ab205dfb2a57c76756faf734e
BLAKE2b-256 checksum
How to use checksums
360a9798c375cc43dab45a89983ba55e1741a11c2474650417b4d7895cc0ae37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / amrita_plugin_deepseek-0.1.6-py3-none-any.whl

Download URL amrita_plugin_deepseek-0.1.6-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9eee89f2156b6161f3f058c33b4faaf91c8205280a16bc16a0e53f46280f8c1
BLAKE2b-256 checksum
How to use checksums
93193e7862d808c5ab4442751f5a3323433340ab0be168eec2f7ef7c932c3ccc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page