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::Textmax_turns: 10temperature:Nonetop_p:Nonetop_k:Nonepresence_penalty:Nonefrequency_penalty:Nonemodalities:Noneaudio:Nonereasoning: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: ResponseFormatOptionThe expected format of the response. Either text or structured output.
max_turns: usizeMax 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>
impl<TCtx> AgentParams<TCtx>
pub fn new(name: &str, model: Arc<dyn LanguageModel + Send + Sync>) -> Self
Sourcepub fn add_instruction(
self,
instruction: impl Into<InstructionParam<TCtx>>,
) -> Self
pub fn add_instruction( self, instruction: impl Into<InstructionParam<TCtx>>, ) -> Self
Add an instruction
Sourcepub fn instructions(self, instructions: Vec<InstructionParam<TCtx>>) -> Self
pub fn instructions(self, instructions: Vec<InstructionParam<TCtx>>) -> Self
Set the instructions
Sourcepub fn add_toolkit(self, toolkit: impl Toolkit<TCtx> + 'static) -> Self
pub fn add_toolkit(self, toolkit: impl Toolkit<TCtx> + 'static) -> Self
Add a toolkit
Sourcepub fn response_format(self, response_format: ResponseFormatOption) -> Self
pub fn response_format(self, response_format: ResponseFormatOption) -> Self
Set the response format
Sourcepub fn temperature(self, temperature: f64) -> Self
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
Sourcepub fn top_p(self, top_p: f64) -> Self
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
Sourcepub fn top_k(self, top_k: i32) -> Self
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.
Sourcepub fn presence_penalty(self, presence_penalty: f64) -> Self
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.
Sourcepub fn frequency_penalty(self, frequency_penalty: f64) -> Self
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.
Sourcepub fn modalities(self, modalities: Vec<Modality>) -> Self
pub fn modalities(self, modalities: Vec<Modality>) -> Self
Set the modalities that the model should support.
Sourcepub fn audio(self, audio: AudioOptions) -> Self
pub fn audio(self, audio: AudioOptions) -> Self
Set the audio options for generation.
Sourcepub fn reasoning(self, reasoning: ReasoningOptions) -> Self
pub fn reasoning(self, reasoning: ReasoningOptions) -> Self
Set the reasoning options for generation.