pub struct AgentRequest<'a, D = String, M = Complete> { /* private fields */ }Expand description
A prepared run of an Agent, created by Agent::run or Agent::run_stream.
Both create the same request with the same with_* methods; only the result of .await
differs. The mode M is Complete for run (a AgentResult) and Streaming for
run_stream (an AgentStream). Nothing is sent to the model before the request is
awaited.
Implementations§
Source§impl<'a, D, M> AgentRequest<'a, D, M>
impl<'a, D, M> AgentRequest<'a, D, M>
Sourcepub fn with_history(self, history: &'a [Message]) -> Self
pub fn with_history(self, history: &'a [Message]) -> Self
Sets the conversation so far. The prompt is sent after these messages.
The history is only read, never changed. Add AgentResult::new_messages to it yourself
once the run succeeds. The system prompt is not part of it: the agent sends its own.
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Uses this model instead of the agent’s model.
Sourcepub fn with_toolbox(self, toolbox: impl ToolBox) -> Self
pub fn with_toolbox(self, toolbox: impl ToolBox) -> Self
Uses this toolbox instead of the agent’s toolbox.
Sourcepub fn with_toolbox_arc(self, toolbox: Arc<dyn ToolBox>) -> Self
pub fn with_toolbox_arc(self, toolbox: Arc<dyn ToolBox>) -> Self
Uses this toolbox, shared in an Arc, instead of the agent’s toolbox.
Sourcepub fn with_max_iterations(self, max_iterations: usize) -> Self
pub fn with_max_iterations(self, max_iterations: usize) -> Self
Uses this iteration limit instead of the agent’s limit.
Sourcepub fn with_chat_options(self, chat_options: ChatOptions) -> Self
pub fn with_chat_options(self, chat_options: ChatOptions) -> Self
Sends these ChatOptions instead of the agent’s options.
Sourcepub fn with_options(self, options: RunOptions) -> Self
pub fn with_options(self, options: RunOptions) -> Self
Applies a set of overrides. Fields set in options replace the ones set before.