pub trait AgentContext: Send + Sync {
// Required methods
fn next_completion<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Vec<ChatMessage>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn current_new_messages<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ChatMessage>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn add_messages<'life0, 'async_trait>(
&'life0 self,
item: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn add_message<'life0, 'async_trait>(
&'life0 self,
item: ChatMessage,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn exec_cmd<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 Command,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ChatMessage>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn redrive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Acts as the interface to the external world and manages messages for completion
Required Methods§
Sourcefn next_completion<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Vec<ChatMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next_completion<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Vec<ChatMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List of all messages for this agent
Used as main source for the next completion and expects all messages to be returned if new messages are present.
Once this method has been called, there should not be new messages
TODO: Figure out a nice way to return a reference instead while still supporting i.e. mutexes
Sourcefn current_new_messages<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ChatMessage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn current_new_messages<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ChatMessage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Lists only the new messages after calling new_completion
Sourcefn add_messages<'life0, 'async_trait>(
&'life0 self,
item: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_messages<'life0, 'async_trait>(
&'life0 self,
item: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add messages for the next completion
Sourcefn add_message<'life0, 'async_trait>(
&'life0 self,
item: ChatMessage,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_message<'life0, 'async_trait>(
&'life0 self,
item: ChatMessage,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add messages for the next completion
Sourcefn exec_cmd<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 Command,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn exec_cmd<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 Command,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute a command if the context supports it
fn history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ChatMessage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn redrive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn redrive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Pops the last messages up until the last completion
LLMs failing completion for various reasons is unfortunately a common occurrence This gives a way to redrive the last completion in a generic way
Trait Implementations§
Source§impl AgentContext for &dyn AgentContext
impl AgentContext for &dyn AgentContext
Source§fn next_completion<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Vec<ChatMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next_completion<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Vec<ChatMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn current_new_messages<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ChatMessage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn current_new_messages<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ChatMessage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
new_completion
Source§fn add_messages<'life0, 'async_trait>(
&'life0 self,
item: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_messages<'life0, 'async_trait>(
&'life0 self,
item: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn add_message<'life0, 'async_trait>(
&'life0 self,
item: ChatMessage,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_message<'life0, 'async_trait>(
&'life0 self,
item: ChatMessage,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn exec_cmd<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 Command,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn exec_cmd<'life0, 'life1, 'async_trait>(
&'life0 self,
cmd: &'life1 Command,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ChatMessage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl AgentContext for Box<dyn AgentContext>
impl AgentContext for Box<dyn AgentContext>
Source§fn next_completion<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Vec<ChatMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next_completion<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Vec<ChatMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn current_new_messages<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ChatMessage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn current_new_messages<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<ChatMessage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
new_completion