AgentParams

Struct AgentParams 

Source
pub struct AgentParams<TCtx> {
Show 15 fields pub name: String, pub model: Arc<dyn LanguageModel + Send + Sync>, pub instructions: Vec<InstructionParam<TCtx>>, pub tools: Vec<Arc<dyn AgentTool<TCtx>>>, pub toolkits: Vec<Arc<dyn Toolkit<TCtx>>>, pub response_format: ResponseFormatOption, pub max_turns: usize, pub temperature: Option<f64>, pub top_p: Option<f64>, pub top_k: Option<i32>, pub presence_penalty: Option<f64>, pub frequency_penalty: Option<f64>, pub modalities: Option<Vec<Modality>>, pub audio: Option<AudioOptions>, pub reasoning: Option<ReasoningOptions>,
}
Expand description

Parameters required to create a new agent.

§Default Values

  • instructions: vec![]
  • tools: vec![]
  • response_format: ResponseFormatOption::Text
  • max_turns: 10
  • temperature: None
  • top_p: None
  • top_k: None
  • presence_penalty: None
  • frequency_penalty: None
  • modalities: None
  • audio: None
  • reasoning: None

Fields§

§name: String§model: Arc<dyn LanguageModel + Send + Sync>

The default language model to use for the agent.

§instructions: Vec<InstructionParam<TCtx>>

Instructions to be added to system messages when executing the agent. This can include formatting instructions or other guidance for the agent.

§tools: Vec<Arc<dyn AgentTool<TCtx>>>

The tools that the agent can use to perform tasks.

§toolkits: Vec<Arc<dyn Toolkit<TCtx>>>

Optional toolkits that can provide dynamic tools and system prompts for each session.

§response_format: ResponseFormatOption

The expected format of the response. Either text or structured output.

§max_turns: usize

Max number of turns for agent to run to protect against infinite loops.

§temperature: Option<f64>

Amount of randomness injected into the response. Ranges from 0.0 to 1.0

§top_p: Option<f64>

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. Ranges from 0.0 to 1.0

§top_k: Option<i32>

Only sample from the top K options for each subsequent token. Used to remove ‘long tail’ low probability responses. Must be a non-negative integer.

§presence_penalty: Option<f64>

Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.

§frequency_penalty: Option<f64>

Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.

§modalities: Option<Vec<Modality>>

The modalities that the model should support.

§audio: Option<AudioOptions>

Options for audio generation.

§reasoning: Option<ReasoningOptions>

Options for reasoning generation.

Implementations§

Source§

impl<TCtx> AgentParams<TCtx>
where TCtx: Send + Sync + 'static,

Source

pub fn new(name: &str, model: Arc<dyn LanguageModel + Send + Sync>) -> Self

Source

pub fn add_instruction( self, instruction: impl Into<InstructionParam<TCtx>>, ) -> Self

Add an instruction

Source

pub fn instructions(self, instructions: Vec<InstructionParam<TCtx>>) -> Self

Set the instructions

Source

pub fn add_tool(self, tool: impl AgentTool<TCtx> + 'static) -> Self

Add a tool

Source

pub fn add_toolkit(self, toolkit: impl Toolkit<TCtx> + 'static) -> Self

Add a toolkit

Source

pub fn toolkits(self, toolkits: Vec<Arc<dyn Toolkit<TCtx>>>) -> Self

Set the toolkits

Source

pub fn response_format(self, response_format: ResponseFormatOption) -> Self

Set the response format

Source

pub fn max_turns(self, max_turns: usize) -> Self

Set the max turns

Source

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

Set the temperature for sampling Amount of randomness injected into the response. Ranges from 0.0 to 1.0

Source

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

Set the top_p for nucleus sampling An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. Ranges from 0.0 to 1.0

Source

pub fn top_k(self, top_k: i32) -> Self

Set the top_k for sampling Only sample from the top K options for each subsequent token. Used to remove ‘long tail’ low probability responses. Must be a non-negative integer.

Source

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

Set the presence penalty Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.

Source

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

Set the frequency penalty Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.

Source

pub fn modalities(self, modalities: Vec<Modality>) -> Self

Set the modalities that the model should support.

Source

pub fn audio(self, audio: AudioOptions) -> Self

Set the audio options for generation.

Source

pub fn reasoning(self, reasoning: ReasoningOptions) -> Self

Set the reasoning options for generation.

Source

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

Auto Trait Implementations§

§

impl<TCtx> Freeze for AgentParams<TCtx>

§

impl<TCtx> !RefUnwindSafe for AgentParams<TCtx>

§

impl<TCtx> Send for AgentParams<TCtx>

§

impl<TCtx> Sync for AgentParams<TCtx>

§

impl<TCtx> Unpin for AgentParams<TCtx>

§

impl<TCtx> !UnwindSafe for AgentParams<TCtx>

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> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

type Error = Infallible

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,