pub trait Agent<S: Send + Sync + Clone + 'static = ()>: Clone {
// Required methods
fn add_action(&mut self, action: Arc<FunctionAction<S>>);
fn system_prompt(&self) -> &str;
fn state(&self) -> AgentState<S>;
fn process_prompt(
&self,
prompt: &str,
history_id: &str,
send_state: Value,
) -> Pin<Box<dyn Future<Output = Result<(String, Option<(Value, ConfirmHandler<S>)>), String>> + Send + Sync>>;
// Provided method
fn add_action_group<G: ActionGroup<S>>(&mut self, group: &G) { ... }
}Expand description
Agent trait represents an LLM with state management capabilities The state type S must be Send + Sync + Clone + ’static
Required Methods§
Sourcefn add_action(&mut self, action: Arc<FunctionAction<S>>)
fn add_action(&mut self, action: Arc<FunctionAction<S>>)
Adds a tool to the agent
Sourcefn system_prompt(&self) -> &str
fn system_prompt(&self) -> &str
Returns the system prompt for the agent
Sourcefn state(&self) -> AgentState<S>
fn state(&self) -> AgentState<S>
Returns a reference to the agent’s state
Sourcefn process_prompt(
&self,
prompt: &str,
history_id: &str,
send_state: Value,
) -> Pin<Box<dyn Future<Output = Result<(String, Option<(Value, ConfirmHandler<S>)>), String>> + Send + Sync>>
fn process_prompt( &self, prompt: &str, history_id: &str, send_state: Value, ) -> Pin<Box<dyn Future<Output = Result<(String, Option<(Value, ConfirmHandler<S>)>), String>> + Send + Sync>>
Takes in a prompt and returns the stringified response. This will automatically add the tool calls to the prompt.
Provided Methods§
Sourcefn add_action_group<G: ActionGroup<S>>(&mut self, group: &G)
fn add_action_group<G: ActionGroup<S>>(&mut self, group: &G)
Adds all actions from an action group
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.