LlmAgentConfig

Struct LlmAgentConfig 

Source
pub struct LlmAgentConfig {
Show 24 fields pub name: String, pub model: Option<String>, pub instruction: Option<String>, pub global_instruction: Option<String>, pub tools: Option<Vec<Arc<dyn ToolFunction>>>, pub generate_content_config: Option<Value>, pub disallow_transfer_to_parent: Option<bool>, pub disallow_transfer_to_peers: Option<bool>, pub include_contents: Option<String>, pub input_schema: Option<Value>, pub output_schema: Option<Value>, pub output_key: Option<String>, pub request_processors: Option<Vec<Value>>, pub response_processors: Option<Vec<Value>>, pub code_executor: Option<Value>, pub description: Option<String>, pub parent_agent: Option<Arc<dyn Agent>>, pub sub_agents: Option<Vec<Arc<dyn Agent>>>, pub before_model_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>, pub after_model_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>, pub before_tool_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>, pub after_tool_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>, pub before_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>, pub after_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>,
}
Expand description

The configuration options for creating an LLM-based agent. (Inherits fields from BaseAgent)

Fields§

§name: String§model: Option<String>

The model to use for the agent.

§instruction: Option<String>

Instructions for the LLM model, guiding the agent’s behavior.

§global_instruction: Option<String>

Instructions for all the agents in the entire agent tree. ONLY the globalInstruction in root agent will take effect. For example: use globalInstruction to make all agents have a stable identity or personality.

§tools: Option<Vec<Arc<dyn ToolFunction>>>

Tools available to this agent.

§generate_content_config: Option<Value>

The additional content generation configurations. NOTE: not all fields are usable, e.g. tools must be configured via tools, thinking_config must be configured via planner in LlmAgent. For example: use this config to adjust model temperature, configure safety settings, etc.

§disallow_transfer_to_parent: Option<bool>

Disallows LLM-controlled transferring to the parent agent. NOTE: Setting this as True also prevents this agent to continue reply to the end-user. This behavior prevents one-way transfer, in which end-user may be stuck with one agent that cannot transfer to other agents in the agent tree.

§disallow_transfer_to_peers: Option<bool>

Disallows LLM-controlled transferring to the peer agents.

§include_contents: Option<String>

Controls content inclusion in model requests. Options: default: Model receives relevant conversation history none: Model receives no prior history, operates solely on current instruction and input

§input_schema: Option<Value>

The input schema when agent is used as a tool.

§output_schema: Option<Value>

The output schema when agent replies.

§output_key: Option<String>

The key in session state to store the output of the agent. Typically use cases: - Extracts agent reply for later use, such as in tools, callbacks, etc. - Connects agents to coordinate with each other.

§request_processors: Option<Vec<Value>>

Processors to run before the LLM request is sent.

§response_processors: Option<Vec<Value>>

Processors to run after the LLM response is received.

§code_executor: Option<Value>

Instructs the agent to make a plan and execute it step by step.

§description: Option<String>§parent_agent: Option<Arc<dyn Agent>>§sub_agents: Option<Vec<Arc<dyn Agent>>>§before_model_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>

Callbacks to be called before calling the LLM.

§after_model_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>

Callbacks to be called after calling the LLM.

§before_tool_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>

Callbacks to be called before calling the tool.

§after_tool_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>

Callbacks to be called after calling the tool.

§before_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>§after_agent_callback: Option<Box<dyn Fn(&InvocationContext) + Send + Sync>>

Implementations§

Source§

impl LlmAgentConfig

Source

pub fn new(name: impl Into<String>) -> Self

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

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
§

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

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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