LLMling

LLMling

易于使用的MCP(模型上下文协议)服务器和AI代理,以YAML定义。

PyPI License Python version Code style: black

LLMling 是一个声明式 LLM 应用开发框架,专注于资源管理、提示模板和工具执行。

核心概念

  • 静态声明:通过 YAML 文件定义 LLM 环境,无需编写代码
  • 组件类型
    • 资源:内容提供者(文件、文本、CLI 输出等)
    • 提示:带参数的消息模板
    • 工具:可由 LLM 调用的 Python 函数

快速开始

1. 安装

pip install llmling

2. 创建配置文件

使用 CLI 创建基本配置:

llmling config create my-config

3. 定义资源、提示和工具

编辑生成的 YAML 配置文件,添加您需要的组件:

resources:
  my_text:
    type: text
    content: "这是一些示例内容"

prompts:
  greeting:
    content: "你好 {{name}},今天天气不错!"

tools:
  calculator:
    function: "math.sqrt"
    description: "计算平方根"

4. 使用配置

通过 MCP 服务器使用您的配置:

# 安装服务器
pip install mcp-server-llmling

# 启动服务器
mcp-server-llmling start --config my-config

或通过代理使用:

# 安装代理
pip install llmling-agent

# 运行代理
llmling-agent run --config my-config

5. 访问组件

列出可用资源:

llmling resources list

渲染提示:

llmling prompts render greeting --params '{"name": "世界"}'

执行工具:

llmling tools execute calculator --args '[16]'

系统要求

  • Python 3.12 或更高版本
  • 基于 pydantic 构建,支持 100% 类型化

更多详细信息,请访问 GitHub 仓库