Skip to content

Latest commit

 

History

History
132 lines (107 loc) · 5.31 KB

README.md

File metadata and controls

132 lines (107 loc) · 5.31 KB

Rig

crates.io docs.rs Discord Ryzome

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

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-inspect, rig-traffic and rig-claude-cloak.

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.

Built by Playgrounds