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>
在正常情况下,这些标记会由模型运行时自动解析,最终用户不会看到任何 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.80.5-0.6: 低敏感度,适合宽松环境0.65-0.7: 中等敏感度,推荐默认值0.75-0.8: 高敏感度,适合高安全要求环境
-
APPEND_TOOL:- 类型: 布尔值 (true/false)
- 默认值:
false - 说明: 是否将工具调用结果追加到模型上下文中。
- 建议: 默认关闭
注意: 修改配置后需要重启应用才能生效。
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file amrita_plugin_deepseek-0.1.5.tar.gz.
File metadata
- Download URL: amrita_plugin_deepseek-0.1.5.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b31c6a9b23ed785db619fe280fa70028c5aacd5f2d2b0808d1ce82f157686277
|
|
| MD5 |
4a7ff3bc29c338fdfe4c06be654e8669
|
|
| BLAKE2b-256 |
fae15afc866d88e55c96ffd56e7f8658ee36d7d5454248b4aa739116ffa7e49e
|
File details
Details for the file amrita_plugin_deepseek-0.1.5-py3-none-any.whl.
File metadata
- Download URL: amrita_plugin_deepseek-0.1.5-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e10f69ecf02414bfa118eac10e4072f985a552a2482b7e27358936374c8f453a
|
|
| MD5 |
571176c3c628c9e591ca4d8776efe742
|
|
| BLAKE2b-256 |
bc572a23fca9d2a01e8ab8839641af968ed57c3a37d1d8af91178705fda3f060
|