关于
⚙️🦀 使用 Rust 构建模块化且可扩展的 LLM 应用
人工智能与机器学习实测星标增长
- 24小时
- +14
- 7天
- +96
- 15天
- +199
- 1个月
- +322
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
Rig is a Rust library for building applications on large language models.
It also ships rig, a terminal coding agent built on the library that you
extend with Bevy plugins.
The coding agent
cargo install rig
rig
This installs the launcher of the latest release. Each release's guide is on
its tag, such as
0.47.0's guide.
The agent guide on main can be ahead of the
release, and shows how to install main from a checkout. The agent needs Rust
1.97.1 or newer and runs on Linux and macOS.
The first rig builds the agent, which takes several minutes, and opens it.
Run /login to sign in or save an API key, or export one such as
OPENAI_API_KEY before starting. /model picks a model and /help lists
the commands. rig -p "fix the failing test" answers one prompt and exits.
Its tools, commands, sessions, sign-in and terminal view are each a plugin,
so any of them can be turned off, replaced or added to. /reload rebuilds
the agent with your changes and keeps the session.
- The agent guide covers updating, models, sessions, tools, settings and scripting.
- The plugin guide explains the basics of a plugin and points at working examples of each kind.
The library
cargo add rig anyhow
cargo add tokio --features macros,rt-multi-thread
use rig::prelude::*;
use rig::providers::openai::{self, OpenAI};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Reads OPENAI_API_KEY.
let model = OpenAI::from_env()?.completion(openai::GPT_6_2_SOL);
let agent = AgentBuilder::new(model)
.preamble("You are a comedian.")
.build();
let response = agent.prompt("Entertain me!").await?;
println!("{}", response.output());
Ok(())
}
Rig puts over 20 model providers and a dozen vector stores behind one
interface. It has agents with tools, streaming and typed hooks. It covers
completion, embedding, transcription, audio and image models and follows the
OpenTelemetry GenAI conventions. rig-core and rig-agent build for browser
WASM. See examples/, the guides and the
API reference.
Crates
The rig crate re-exports rig-core. Its default features add rig-agent,
the derive macros, the reqwest HTTP client with rustls and, on native targets,
the rig launcher (feature cli, from rig-cli); default-features = false
leaves them out. Each crate in the list below is a feature named after it
without rig-:
cargo add rig --features memory,fastembed
- Agents and state:
rig-agent,rig-memory(saved conversations),rig-cassette(record and replay),rig-rmcp(MCP tools). - Models:
rig-bedrock,rig-vertexai,rig-gemini-grpc,rig-candle(local models),rig-fastembed(local embeddings),rig-typesafeai(TypeSafe Jev judgments).
The vector stores, such as LanceDB, Qdrant and PostgreSQL, are companion crates behind features too; docs.rs lists every feature.
Internals: rig-core (messages, models, tools,
providers), rig-derive (feature derive),
rig-http (transport traits),
rig-reqwest (feature reqwest) and
rig-tungstenite (feature websocket).
Coding agent: rig-cli (feature cli, the library of the rig binary)
and, not facade features, rig-harness,
rig-harness-protocol,
rig-ecs, rig-tools,
rig-markdown, and the plugins
rig-basics, rig-tui,
rig-fold, rig-steel,
rig-mcp-client, rig-acp,
rig-linear,
rig-inspect, rig-traffic,
rig-bridge and rig-watch.
Community
Ask questions on Discord. CONTRIBUTING.md says how to contribute, and awesome-rig lists projects built on Rig.
Rig is pre-1.0, so releases break APIs. The changelog and migration notes say what changed. Rig is MIT licensed.
探索相关项目
加载中…