AsyncCallbackHandler

Trait AsyncCallbackHandler 

Source
pub trait AsyncCallbackHandler: BaseCallbackHandler {
Show 19 methods // Provided methods fn on_llm_start_async<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, serialized: &'life1 HashMap<String, Value>, prompts: &'life2 [String], run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait { ... } fn on_chat_model_start_async<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, serialized: &'life1 HashMap<String, Value>, messages: &'life2 [Vec<BaseMessage>], run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait { ... } fn on_llm_new_token_async<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, token: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, chunk: Option<&'life2 Value>, tags: Option<&'life3 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait { ... } fn on_llm_end_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, response: &'life1 ChatResult, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_llm_error_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, error: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_chain_start_async<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, serialized: &'life1 HashMap<String, Value>, inputs: &'life2 HashMap<String, Value>, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait { ... } fn on_chain_end_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, outputs: &'life1 HashMap<String, Value>, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_chain_error_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, error: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_tool_start_async<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 mut self, serialized: &'life1 HashMap<String, Value>, input_str: &'life2 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, inputs: Option<&'life5 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait { ... } fn on_tool_end_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, output: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_tool_error_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, error: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_text_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, text: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_retry_async<'life0, 'life1, 'async_trait>( &'life0 mut self, retry_state: &'life1 Value, run_id: Uuid, parent_run_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn on_agent_action_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, action: &'life1 Value, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_agent_finish_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, finish: &'life1 Value, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_retriever_start_async<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, serialized: &'life1 HashMap<String, Value>, query: &'life2 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait { ... } fn on_retriever_end_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, documents: &'life1 [Value], run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_retriever_error_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, error: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn on_custom_event_async<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, name: &'life1 str, data: &'life2 Value, run_id: Uuid, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait { ... }
}
Expand description

Async callback handler for LangChain.

This trait provides async versions of all callback methods.

Provided Methods§

Source

fn on_llm_start_async<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, serialized: &'life1 HashMap<String, Value>, prompts: &'life2 [String], run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Run when LLM starts running (async).

Source

fn on_chat_model_start_async<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, serialized: &'life1 HashMap<String, Value>, messages: &'life2 [Vec<BaseMessage>], run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Run when a chat model starts running (async).

Source

fn on_llm_new_token_async<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, token: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, chunk: Option<&'life2 Value>, tags: Option<&'life3 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Run on new output token (async).

Source

fn on_llm_end_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, response: &'life1 ChatResult, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run when LLM ends running (async).

Source

fn on_llm_error_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, error: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run when LLM errors (async).

Source

fn on_chain_start_async<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, serialized: &'life1 HashMap<String, Value>, inputs: &'life2 HashMap<String, Value>, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Run when chain starts running (async).

Source

fn on_chain_end_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, outputs: &'life1 HashMap<String, Value>, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run when chain ends running (async).

Source

fn on_chain_error_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, error: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run when chain errors (async).

Source

fn on_tool_start_async<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 mut self, serialized: &'life1 HashMap<String, Value>, input_str: &'life2 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, inputs: Option<&'life5 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Run when tool starts running (async).

Source

fn on_tool_end_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, output: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run when tool ends running (async).

Source

fn on_tool_error_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, error: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run when tool errors (async).

Source

fn on_text_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, text: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run on an arbitrary text (async).

Source

fn on_retry_async<'life0, 'life1, 'async_trait>( &'life0 mut self, retry_state: &'life1 Value, run_id: Uuid, parent_run_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Run on a retry event (async).

Source

fn on_agent_action_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, action: &'life1 Value, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run on agent action (async).

Source

fn on_agent_finish_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, finish: &'life1 Value, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run on the agent end (async).

Source

fn on_retriever_start_async<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, serialized: &'life1 HashMap<String, Value>, query: &'life2 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Run on the retriever start (async).

Source

fn on_retriever_end_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, documents: &'life1 [Value], run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run on the retriever end (async).

Source

fn on_retriever_error_async<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, error: &'life1 str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&'life2 [String]>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Run on retriever error (async).

Source

fn on_custom_event_async<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, name: &'life1 str, data: &'life2 Value, run_id: Uuid, tags: Option<&'life3 [String]>, metadata: Option<&'life4 HashMap<String, Value>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Override to define a handler for custom events (async).

Implementors§