pub struct DefaultContext { /* private fields */ }
Implementations§
Source§impl DefaultContext
impl DefaultContext
Sourcepub fn from_executor<T: Into<Arc<dyn ToolExecutor>>>(
executor: T,
) -> DefaultContext
pub fn from_executor<T: Into<Arc<dyn ToolExecutor>>>( executor: T, ) -> DefaultContext
Create a new context with a custom executor
Sourcepub fn with_stop_on_assistant(&mut self, stop: bool) -> &mut Self
pub fn with_stop_on_assistant(&mut self, stop: bool) -> &mut Self
If set to true, the agent will stop if the last message is from the assistant (i.e. no new tool calls, summaries or user messages)
pub fn with_message_history( &mut self, backend: impl MessageHistory + 'static, ) -> &mut Self
Sourcepub async fn with_existing_messages<I: IntoIterator<Item = ChatMessage>>(
&mut self,
message_history: I,
) -> Result<&mut Self>
pub async fn with_existing_messages<I: IntoIterator<Item = ChatMessage>>( &mut self, message_history: I, ) -> Result<&mut Self>
Sourcepub fn with_tool_feedback(
&mut self,
feedback: impl Into<HashMap<ToolCall, ToolFeedback>>,
)
pub fn with_tool_feedback( &mut self, feedback: impl Into<HashMap<ToolCall, ToolFeedback>>, )
Trait Implementations§
Source§impl AgentContext for DefaultContext
impl AgentContext for DefaultContext
Source§fn next_completion<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<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 = Result<Option<Vec<ChatMessage>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieve messages for the next completion
Source§fn current_new_messages<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<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 = Result<Vec<ChatMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns the messages the agent is currently completing on
Source§fn history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieve all messages in the conversation history
Source§fn add_messages<'life0, 'async_trait>(
&'life0 self,
messages: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_messages<'life0, 'async_trait>(
&'life0 self,
messages: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add multiple messages to the conversation history
Source§fn add_message<'life0, 'async_trait>(
&'life0 self,
item: ChatMessage,
) -> Pin<Box<dyn Future<Output = Result<()>> + 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 = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add a single message to the conversation history
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,
👎Deprecated: use executor instead
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 in the tool executor
Source§fn redrive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn redrive<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Pops the last messages up until the previous 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
fn executor(&self) -> &Arc<dyn ToolExecutor>
Source§fn has_received_feedback<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_call: &'life1 ToolCall,
) -> Pin<Box<dyn Future<Output = Option<ToolFeedback>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn has_received_feedback<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_call: &'life1 ToolCall,
) -> Pin<Box<dyn Future<Output = Option<ToolFeedback>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Tools that require feedback or approval (i.e. from a human) can use this to check if the
feedback is received
fn feedback_received<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_call: &'life1 ToolCall,
feedback: &'life2 ToolFeedback,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§impl Clone for DefaultContext
impl Clone for DefaultContext
Source§fn clone(&self) -> DefaultContext
fn clone(&self) -> DefaultContext
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for DefaultContext
impl Debug for DefaultContext
Auto Trait Implementations§
impl Freeze for DefaultContext
impl !RefUnwindSafe for DefaultContext
impl Send for DefaultContext
impl Sync for DefaultContext
impl Unpin for DefaultContext
impl !UnwindSafe for DefaultContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more