pub struct AgentBuilder<M: CompletionModel> { /* private fields */ }
Expand description
A builder for creating an agent
§Example
use rig::{providers::openai, agent::AgentBuilder};
let openai = openai::Client::from_env();
let gpt4o = openai.completion_model("gpt-4o");
// Configure the agent
let agent = AgentBuilder::new(model)
.preamble("System prompt")
.context("Context document 1")
.context("Context document 2")
.tool(tool1)
.tool(tool2)
.temperature(0.8)
.additional_params(json!({"foo": "bar"}))
.build();
Implementations§
Source§impl<M: CompletionModel> AgentBuilder<M>
impl<M: CompletionModel> AgentBuilder<M>
pub fn new(model: M) -> Self
Sourcepub fn append_preamble(self, doc: &str) -> Self
pub fn append_preamble(self, doc: &str) -> Self
Append to the preamble of the agent
Sourcepub fn dynamic_context(
self,
sample: usize,
dynamic_context: impl VectorStoreIndexDyn + 'static,
) -> Self
pub fn dynamic_context( self, sample: usize, dynamic_context: impl VectorStoreIndexDyn + 'static, ) -> Self
Add some dynamic context to the agent. On each prompt, sample
documents from the
dynamic context will be inserted in the request.
Sourcepub fn dynamic_tools(
self,
sample: usize,
dynamic_tools: impl VectorStoreIndexDyn + 'static,
toolset: ToolSet,
) -> Self
pub fn dynamic_tools( self, sample: usize, dynamic_tools: impl VectorStoreIndexDyn + 'static, toolset: ToolSet, ) -> Self
Add some dynamic tools to the agent. On each prompt, sample
tools from the
dynamic toolset will be inserted in the request.
Sourcepub fn temperature(self, temperature: f64) -> Self
pub fn temperature(self, temperature: f64) -> Self
Set the temperature of the model
Sourcepub fn max_tokens(self, max_tokens: u64) -> Self
pub fn max_tokens(self, max_tokens: u64) -> Self
Set the maximum number of tokens for the completion
Sourcepub fn additional_params(self, params: Value) -> Self
pub fn additional_params(self, params: Value) -> Self
Set additional parameters to be passed to the model
Auto Trait Implementations§
impl<M> Freeze for AgentBuilder<M>where
M: Freeze,
impl<M> !RefUnwindSafe for AgentBuilder<M>
impl<M> Send for AgentBuilder<M>
impl<M> Sync for AgentBuilder<M>
impl<M> Unpin for AgentBuilder<M>where
M: Unpin,
impl<M> !UnwindSafe for AgentBuilder<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more