Skip to main content

ic_rig/
lib.rs

1//! `irig` — a lean, modular library for building LLM applications.
2//!
3//! Designed to run anywhere, including ICP WASM canisters. There is **no**
4//! bundled HTTP client; you provide one by implementing [`http::HttpClient`].
5//!
6//! # Crate layout
7//!
8//! | Module | Purpose |
9//! |---|---|
10//! | [`message`] | Core message types (`Message`, `ToolCall`, …) |
11//! | [`completion`] | `CompletionModel` trait + request/response types |
12//! | [`tool`] | `Tool` trait + type-erased `ToolSet` |
13//! | [`agent`] | `Agent` + `AgentBuilder` (drives the agentic loop) |
14//! | [`http`] | `HttpClient` trait — implement this for your platform |
15//! | [`wasm_compat`] | `WasmCompatSend`/`WasmCompatSync` shims |
16//!
17//! # Quick start
18//!
19//! ```rust,ignore
20//! use irig::{
21//!     agent::Agent,
22//!     completion::{CompletionModel, CompletionRequest, CompletionResponse},
23//!     http::HttpClient,
24//! };
25//!
26//! // 1. Implement HttpClient for your platform.
27//! // 2. Implement CompletionModel wrapping that client.
28//! // 3. Build an Agent and call .prompt().
29//!
30//! let agent = Agent::builder(my_model)
31//!     .preamble("You are a helpful assistant.")
32//!     .max_tokens(512)
33//!     .build();
34//!
35//! let reply = agent.prompt("Hello!").await?;
36//! ```
37
38pub mod agent;
39pub mod completion;
40pub mod embeddings;
41pub mod http;
42pub mod message;
43pub mod providers;
44pub mod tool;
45pub mod vector_store;
46pub mod wasm_compat;
47
48// Flat re-exports for convenience.
49pub use agent::{Agent, AgentBuilder, AgentError};
50pub use completion::{CompletionError, CompletionModel, CompletionRequest, CompletionResponse, ModelChoice, Usage};
51pub use embeddings::{DistanceMetric, Embed, EmbedError, EmbeddingModel, EmbeddingsBuilder, Embedding, EmbeddingError, VectorDistance};
52pub use http::{HttpClient, HttpRequest, HttpResponse};
53pub use message::{AssistantContent, Message, Text, ToolCall, ToolResult, UserContent};
54pub use tool::{Tool, ToolDefinition, ToolError, ToolSet};
55pub use wasm_compat::{BoxFuture, WasmCompatSend, WasmCompatSync};