Expand description
This module contains the implementation of the Agent
struct and its builder.
The Agent
struct represents an LLM agent, which combines an LLM model with a preamble (system prompt),
a set of context documents, and a set of static tools. The agent can be used to interact with the LLM model
by providing prompts and chat history.
The AgentBuilder
struct provides a builder pattern for creating instances of the Agent
struct.
It allows configuring the model, preamble, context documents, static tools, temperature, and additional parameters
before building the agent.
§Example
use rig::{completion::Prompt, providers::openai};
let openai_client = openai::Client::from_env();
// Configure the model
let model = client.model("gpt-4o")
.temperature(0.8)
.build();
// Use the model for completions and prompts
let completion_req_builder = model.completion("Prompt", chat_history).await;
let chat_response = model.chat("Prompt", chat_history).await;
For more information on how to use the Agent
struct and its builder, refer to the documentation of the respective structs and methods.
Structs§
- A model that can be used to prompt completions from a completion model. This is the simplest building block for creating an LLM powered application.
- A builder for creating a model