Skip to main content

Module core

Module core 

Source
Expand description

Direct access to portable provider, data, memory, and tool contracts.

This explicit namespace is also the stable expansion root for portable #[rig_tool] functions in crates that depend on rig-agent without a separate direct rig-core dependency.

Portable rig-core root items are reachable here, but deliberately not at the rig_agent crate root — adding a root export to rig-core must not silently add one to rig-agent. A stable rig-core root export (rig_core::OneOrMany) demonstrates both halves of that invariant (the two doctests below enforce it):

// Reachable through the explicit `core` namespace.
use rig_agent::core::OneOrMany;
let _reachable: Option<OneOrMany<u8>> = None;
// NOT reachable at the `rig_agent` crate root.
use rig_agent::OneOrMany as _;

Modules§

audio_generationaudio
Everything related to audio generation (ie, Text To Speech). Rig abstracts over a number of different providers using the AudioGenerationModel trait.
client
This module provides traits for defining and creating provider clients. Clients are used to create models for completion, embeddings, etc.
completion
Provider-agnostic completion and chat abstractions.
embeddings
Provider-agnostic embedding abstractions.
http_client
id
Lightweight generation of short, unique, URL-safe identifiers.
image_generationimage
Everything related to core image generation abstractions in Rig. Rig allows calling a number of different providers (that support image generation) using the ImageGenerationModel trait.
loaders
File loading utilities for preparing local documents as model or embedding input.
markers
Common marker traits and structs for type-safe builders.
memory
Conversation memory: Rig-managed persistent conversation history for agents.
model
Model metadata returned by providers with model listing support.
one_or_many
prelude
The rig prelude.
providers
Provider integrations included in rig-core.
rerank
Provider-agnostic reranking abstractions.
schemars
Schemars
serde
Serde
streaming
This module provides functionality for working with streaming completion models. It provides traits and types for generating streaming completion requests and handling streaming completion responses.
telemetry
This module primarily concerns being able to orchestrate telemetry across a given pipeline or workflow. This includes tracing, being able to send traces to an OpenTelemetry collector, setting up your agents with the correct tracing style so you can emit the right traces for platforms like Langfuse, and more.
test_utilstest-utils
Test utilities for deterministic completion-model tests.
tool
Portable tool contracts and canonical execution values.
transcription
This module provides functionality for working with audio transcription models. It provides traits, structs, and enums for generating audio transcription requests, handling transcription responses, and defining transcription models.
vector_store
Vector store abstractions for semantic search and retrieval.
wasm_compat

Macros§

completion_parent_span
Declare a completion-parent span conforming to the adoption contract.
if_not_wasm
if_wasm

Structs§

EmptyListError
Error type for when trying to create a OneOrMany object with an empty vector.
OneOrMany
Struct containing either a single item or a list of items of type T. If a single item is present, first will contain it and rest will be empty. If multiple items are present, first will contain the first item and rest will contain the rest. IMPORTANT: this struct cannot be created with an empty vector. OneOrMany objects can only be created using OneOrMany::from() or OneOrMany::try_from().
ProviderResponseError
A raw error response preserved from a provider.

Traits§

Embed
Derive this trait for objects that need to be converted to vector embeddings. The Embed::embed method accumulates string values that need to be embedded by adding them to the TextEmbedder. If an error occurs, the method should return EmbedError.

Attribute Macros§

rig_tool
A procedural macro that transforms a function into a portable rig_core::tool::PortableTool, or into the classic contextual rig::tool::Tool when the function accepts classic runtime context.
tool_macro
A procedural macro that transforms a function into a portable rig_core::tool::PortableTool, or into the classic contextual rig::tool::Tool when the function accepts classic runtime context.

Derive Macros§

Embed
A macro that allows you to implement the rig::embedding::Embed trait by deriving it. Usage can be found below: