Agent

Trait Agent 

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

Source

fn add_action(&mut self, action: Arc<FunctionAction<S>>)

Adds a tool to the agent

Source

fn system_prompt(&self) -> &str

Returns the system prompt for the agent

Source

fn state(&self) -> AgentState<S>

Returns a reference to the agent’s state

Source

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§

Source

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.

Implementors§

Source§

impl Agent for NullAgent

Source§

impl<S, T> Agent<S> for TextAgent<S, T>
where S: Send + Sync + Clone + 'static, T: Agent + Send + Sync + 'static,