0xPlaygrounds/rig
GitHub: 0xPlaygrounds/rig
Rig 是一个 Rust 语言的 LLM 应用开发框架,通过统一接口整合多模型提供商和向量存储,帮助开发者快速构建可扩展的 AI 代理和 RAG 系统。
Stars: 6199 | Forks: 673
[📑 文档](https://docs.rig.rs)
•
[🌐 官网](https://rig.rs)
•
[🤝 贡献](https://github.com/0xPlaygrounds/rig/issues/new)
•
[✍🏽 博客](https://docs.rig.rs/guides)
## 目录
- [目录](#table-of-contents)
- [什么是 Rig?](#what-is-rig)
- [核心功能](#high-level-features)
- [谁在使用 Rig?](#who-is-using-rig)
- [开始使用](#get-started)
- [简单示例](#simple-example)
- [集成](#supported-integrations)
## 什么是 Rig?
Rig 是一个 Rust 库,用于构建可扩展、模块化且符合人体工程学的 **LLM 驱动**应用程序。
关于该 crate 的更多信息,请参阅 [官方](https://docs.rig.rs) 和 [crate](https://docs.rs/rig-core/latest/rig/)(API 参考)文档。
## 功能特性
- 能够处理多轮流式传输和提示的 Agentic workflows
- 完全兼容 [GenAI Semantic Convention](https://opentelemetry.io/docs/specs/semconv/gen-ai/)
- 20 多个模型提供商,全部通过统一的接口访问
- 10 多个向量存储集成,全部通过统一的接口访问
- 全面支持 LLM 补全和嵌入工作流
- 支持转录、音频生成和图像生成模型能力
- 以极少的样板代码将 LLM 集成到您的应用中
- 完全兼容 WASM(仅核心库)
## 谁在使用 Rig?
以下列出了部分正在使用 Rig 的公司和人员(非详尽列表):
- [St Jude](https://www.stjude.org/) - 将 Rig 用于基因组可视化工具 [`proteinpaint`](https://github.com/stjude/proteinpaint) 中的聊天机器人实用程序。
- [Coral Protocol](https://www.coralprotocol.org/) - 在内部以及 [Coral Rust SDK](https://github.com/Coral-Protocol/coral-rs) 中广泛使用 Rig。
- [VT Code](https://github.com/vinhnx/vtcode) - VT Code 是一个基于 Rust 的终端编码代理,通过 Tree-sitter 和 ast-grep 提供语义代码智能。VT Code 使用 `rig` 来简化 LLM 调用并实现模型选择器。
- [Dria](https://dria.co/) - 一个去中心化 AI 网络。目前在其 [计算节点](https://github.com/firstbatchxyz/dkn-compute-node) 中使用 Rig。
- [Nethermind](https://www.nethermind.io/) - 在其 [Neural Interconnected Nodes Engine](https://github.com/NethermindEth/nine) 框架中使用 Rig。
- [Neon](https://neon.com) - 在 Rust 重构的 [app.build](https://github.com/neondatabase/appdotbuild-agent) V2 中使用 Rig。
- [Listen](https://github.com/piotrostr/listen) - 一个旨在成为 AI 投资组合管理代理首选框架的项目。为 [Listen 应用](https://app.listen-rs.com/) 提供支持。
- [Cairnify](https://cairnify.com/) - 通过智能搜索栏帮助用户即时查找文档、链接和信息。Rig 为 Cairnify 的 AI 搜索体验提供了 Agentic 基础,实现了工具调用、推理和检索工作流。
- [Ryzome](https://ryzome.ai) - Ryzome 是一个可视化 AI 工作区,允许您构建互联的思维、研究和 AI 代理画布,以编排复杂的知识工作。
- [deepwiki-rs](https://github.com/sopaco/deepwiki-rs) - 将代码转化为清晰度。在几分钟内生成准确的技术文档和 AI 就绪的上下文——结构完美,适合人类团队和智能代理。
- [Cortex Memory](https://github.com/sopaco/cortex-mem) - 面向智能代理的生产级就绪内存系统。完整的内存管理解决方案,涵盖提取和向量搜索到自动优化,开箱即用提供 REST API、MCP、CLI 和洞察仪表板。
- [Ironclaw](https://github.com/nearai/ironclaw) - 一个安全的个人 AI 助手
完整列表请查看我们的 [ECOSYSTEM.md 文件](https://www.github.com/0xPlaygrounds/rig/tree/main/ECOSYSTEM.md)。
您也在使用 Rig 吗?[提交一个 Issue](https://www.github.com/0xPlaygrounds/rig/issues) 将您的名字添加进来!
## 开始使用
```
cargo add rig-core
```
### 简单示例
```
use rig::client::{CompletionClient, ProviderClient};
use rig::completion::Prompt;
use rig::providers::openai;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// Create OpenAI client
let client = openai::Client::from_env();
// Create agent with a single context prompt
let comedian_agent = client
.agent("gpt-5.2")
.preamble("You are a comedian here to entertain the user using humour and jokes.")
.build();
// Prompt the agent and print the response
let response = comedian_agent.prompt("Entertain me!").await?;
println!("{response}");
Ok(())
}
```
请注意,使用 `#[tokio::main]` 需要您启用 tokio 的 `macros` 和 `rt-multi-thread` 功能,
或者直接启用 `full` 以开启所有功能(`cargo add tokio --features macros,rt-multi-thread`)。
您可以在每个 crate 的 `examples`(例如 [`rig/rig-core/examples`](./rig/rig-core/examples)) 目录中找到更多示例。更详细的用例演练会定期发布在我们的 [Dev.to 博客](https://dev.to/0thtachi) 上,并添加到 Rig 的官方文档 [(docs.rig.rs)](http://docs.rig.rs) 中。
## 支持的集成
向量存储以单独的伴随 crate 形式提供:
- MongoDB: [`rig-mongodb`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-mongodb)
- LanceDB: [`rig-lancedb`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-lancedb)
- Neo4j: [`rig-neo4j`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-neo4j)
- Qdrant: [`rig-qdrant`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-qdrant)
- SQLite: [`rig-sqlite`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-sqlite)
- SurrealDB: [`rig-surrealdb`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-surrealdb)
- Milvus: [`rig-milvus`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-milvus)
- ScyllaDB: [`rig-scylladb`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-scylladb)
- AWS S3Vectors: [`rig-s3vectors`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-s3vectors)
- HelixDB: [`rig-helixdb`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-helixdb)
以下提供商以单独的伴随 crate 形式提供:
- AWS Bedrock: [`rig-bedrock`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-bedrock)
- Fastembed: [`rig-fastembed`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-fastembed)
- Eternal AI: [`rig-eternalai`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-eternalai)
- Google Vertex: [`rig-vertexai`](https://github.com/0xPlaygrounds/rig/tree/main/rig-integrations/rig-vertexai)
我们还提供了一些其他相关的 crate,它们具有您在使用 Rig 时可能会发现有用的附加功能:
- `rig-onchain-kit` - [Rig Onchain Kit](https://github.com/0xPlaygrounds/rig-onchain-kit)。旨在使 Solana/EVM 与 Rig 之间的交互更容易实现。
标签:Agent, AI基础设施, AI工程化, Apex, DLL 劫持, LLM, NLP, RAG, Rust, Rust库, Unmanaged PE, Workspace, 低级语言, 可视化界面, 后端开发, 大语言模型, 威胁情报, 开发者工具, 开源库, 搜索引擎爬虫, 机器学习, 检索增强生成, 模块化, 网络流量审计, 通知系统, 通知系统, 高性能计算