DSML patch for deepseek models in Amrita
Project description
amrita_plugin_deepseek
这是一个针对 Amrita 框架的插件,专门用于处理 DeepSeek 模型生成的 DSML (DeepSeek Markup Language) 函数调用标签。该插件能够解析和执行 AI 模型生成的工具调用指令。
功能特点
- DSML 解析: 解析 DeepSeek 模型错误生成的
<|DSML|function_calls>标签 - 工具调用执行: 自动识别并执行模型建议的工具调用
- 参数处理: 正确解析各种类型的参数(字符串、数字、布尔值等)
- 错误处理: 当工具调用出现异常时,优雅地处理错误
- 响应整合: 将工具调用结果重新整合到对话流程中
工作原理
插件通过以下步骤处理包含 DSML 的响应:
- 检测: 在 AI 响应中查找 DSML 标签
- 解析: 解析函数调用和参数
- 执行: 执行对应的工具
- 反馈: 将执行结果添加回对话上下文中
DSML 标签格式
DSML 使用特定格式的 XML 风格标签来表示函数调用:
<|DSML|function_calls>
<|DSML|invoke name="tool_name">
<|DSML|parameter name="param1" type="string">value1</|DSML|parameter>
<|DSML|parameter name="param2" type="number">42</|DSML|parameter>
</|DSML|invoke>
</|DSML|function_calls>
安装方法
使用 uv 安装(推荐):
uv add amrita_plugin_deepseek
或者将此插件加入到你的项目依赖中:
[project]
dependencies = [
"amrita_plugin_deepseek",
]
或者使用 Amrita-CLI 安装
amrita plugin install amrita_plugin_deepseek
配置
此插件不需要额外配置。安装后会自动注册到 Amrita 框架中。
使用示例
当 DeepSeek 模型生成包含 DSML 标签的响应时,插件会自动解析并执行相应的工具调用。例如,如果模型建议使用网络爬虫工具获取信息:
我需要获取 https://amrita.suggar.top/docs 的内容。
<|DSML|function_calls>
<|DSML|invoke name="webscraper">
<|DSML|parameter name="url" string="true">https://amrita.suggar.top/docs</|DSML|parameter>
</|DSML|invoke>
</|DSML|function_calls>
插件会自动执行 webscraper 工具,并将结果返回给模型,然后模型可以基于这些结果继续对话。
支持的适配器
- OneBot V11
依赖项
- Python >= 3.10
- amrita[full] >= 0.7.3.2
开发
环境设置
# 创建虚拟环境
uv venv
# 激活虚拟环境
source .venv/bin/activate # Linux/macOS
# 或
.venv\Scripts\activate # Windows
# 同步依赖
uv sync
许可证
请参阅项目仓库中的许可证文件。
Project details
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.0.tar.gz.
File metadata
- Download URL: amrita_plugin_deepseek-0.1.0.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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 |
74a354e42e95ecec2438660931ac7e91176dd6c38d993ae434575981e74f5caf
|
|
| MD5 |
f8bc2c019689fcd5332c27987d6a0341
|
|
| BLAKE2b-256 |
ed6b20ff363bdcb321b50e3f027b202a2747f80fa5ec017126f0d1c163dbe779
|
File details
Details for the file amrita_plugin_deepseek-0.1.0-py3-none-any.whl.
File metadata
- Download URL: amrita_plugin_deepseek-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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 |
d8feb210e97d06ef6f6ec7dd56b3b21c9bb071e6898296ec1c4a28dcb385e0af
|
|
| MD5 |
5438f1861ecba808ff3896000f6ba3d9
|
|
| BLAKE2b-256 |
e7e1f3e7164ead490197b8684acf79a3a34adec57ee43e4a6de6565907689200
|