Struct rig::agent::AgentBuilder
source · 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 temperature(self, temperature: f64) -> Self
pub fn temperature(self, temperature: f64) -> Self
Set the temperature of the model
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