Skip to main content

利用 LLM 将自然语言转换为机器人指令 / Convert natural language messages into bot commands using LLMs

Project description

NoneBot-Plugin-LLM-Extension

✨ 将自然语言转换为机器人指令 ✨

pypi python uv-managed alc-resolved
NoneBot Registry Supported Adapters
📸 演示与预览   |   📦️ 下载插件   |   💬 加入交流群

📖 介绍 Human coded

利用 LLM 将自然语言转换为机器人指令 / Convert natural language messages into bot commands using LLMs

[!IMPORTANT] 收藏项目,你将从 GitHub 上无延迟地接收所有发布通知~⭐️

starify

💿 安装

以下提到的方法任选 其一 即可

[推荐] 使用 nb-cli 安装 在 Bot 的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-llm-extension
使用包管理器安装
pip install nonebot-plugin-llm-extension
# or, use poetry
poetry add nonebot-plugin-llm-extension
# or, use pdm
pdm add nonebot-plugin-llm-extension
# or, use uv
uv add nonebot-plugin-llm-extension

⚙️ 配置

在项目的配置文件中添加下表中配置:

其实这里并不建议使用 deepseek

配置项 默认值 说明
llm_extension__api_key API 密钥
llm_extension__base_url https://api.deepseek.com/v1 API 端点
llm_extension__model deepseek-reasoner 模型名

🎉 使用

[!NOTE] 为了使 LLM 能够更好地理解和转换用户输入为指令,建议在构造指令时:

  1. 完善命令描述:为每个命令提供清晰、准确的描述信息
  2. 丰富参数说明:详细说明每个参数的含义、类型和取值范围
  3. 提供使用示例:给出具体的操作示例,帮助 LLM 理解命令的使用场景
from nonebot_plugin_llm_extension import LLMExtension
from nonebot_plugin_alconna import on_alconna, Args, Alconna, CommandMeta

weather = on_alconna(
    Alconna(
      "weather",
      Args["location?#地区", str],
      meta=CommandMeta(
        description="今日天气",
        example="/天气 陕西汉中"
      )
    ), 
    use_cmd_start=True,
    extension=[LLMExtension],
)

通过提供完善的命令元信息,可以让 LLM 更准确地理解命令意图,从而提高自然语言到指令的转换准确率

📸 效果图

理论上,这里应该有一张图片

💖 鸣谢

📄 许可证

本项目使用 MIT 许可证开源

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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

nonebot_plugin_llm_extension-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_llm_extension-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_llm_extension-0.1.0.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_llm_extension-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5b168c3dc6568421c771cbed400562da5a8463c746d61d62219eba826d0caf5d
MD5 ba36c1a6eab6749342ee5e576fcb7232
BLAKE2b-256 6ec8f9066049b3b802ed69ecc477daac6f3f012c309bb850e38755b0afdd8acd

See more details on using hashes here.

File details

Details for the file nonebot_plugin_llm_extension-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_llm_extension-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f7a1e2024d2da1a7c29ebaab997b2979426645b553d91b6599031f907772662
MD5 0ade3bcd7373e2b19afb74f5a9d6f975
BLAKE2b-256 e76ca55ade4a7eafcbcbbc7e7c2e106d3e54377b23acaaeb5323bae637eb97e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page