Skip to main content

AgentBuilder

Struct AgentBuilder 

Source
pub struct AgentBuilder<M> { /* private fields */ }
Expand description

Fluent builder for Agent.

Implementations§

Source§

impl<M: CompletionModel> AgentBuilder<M>

Source

pub fn preamble(self, preamble: impl Into<String>) -> Self

Set the system prompt.

Source

pub fn tool<T: Tool + 'static>(self, tool: T) -> Self

Register a tool.

Source

pub fn temperature(self, temperature: f64) -> Self

Set the sampling temperature.

Source

pub fn max_tokens(self, max_tokens: u32) -> Self

Set the maximum tokens to generate.

Source

pub fn max_iterations(self, n: u32) -> Self

Override the default iteration cap (10) for the tool-call loop.

Source

pub fn thinking(self, enabled: bool) -> Self

Explicitly turn the model’s thinking/reasoning mode on (true) or off (false). Leave unset to use the provider’s own default.

Best-effort and provider-specific — see CompletionRequest::thinking for exactly how each provider interprets this. Regardless of this setting, Agent::prompt/Agent::chat only ever return the final answer text — a reasoning trace, if the provider returns one, is never mixed into it.

Source

pub fn context(self, doc: impl Into<String>) -> Self

Append a static context document (e.g. retrieved RAG chunks).

Source

pub fn build(self) -> Agent<M>

Consume the builder and produce an Agent.

Auto Trait Implementations§

§

impl<M> !RefUnwindSafe for AgentBuilder<M>

§

impl<M> !Send for AgentBuilder<M>

§

impl<M> !Sync for AgentBuilder<M>

§

impl<M> !UnwindSafe for AgentBuilder<M>

§

impl<M> Freeze for AgentBuilder<M>
where M: Freeze,

§

impl<M> Unpin for AgentBuilder<M>
where M: Unpin,

§

impl<M> UnsafeUnpin for AgentBuilder<M>
where M: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.