Skip to main content

CallbackHandler

Trait CallbackHandler 

Source
pub trait CallbackHandler: Send + Sync {
Show 15 methods // Provided methods fn on_chain_start(&self, _runnable: &str, _input: &Value, _run_id: Uuid) { ... } fn on_chain_end(&self, _runnable: &str, _output: &Value, _run_id: Uuid) { ... } fn on_chain_error(&self, _runnable: &str, _error: &str, _run_id: Uuid) { ... } fn on_llm_start(&self, _model: &str, _prompt: &Value, _run_id: Uuid) { ... } fn on_llm_token(&self, _token: &str, _run_id: Uuid) { ... } fn on_llm_end(&self, _model: &str, _output: &Value, _run_id: Uuid) { ... } fn on_llm_error(&self, _model: &str, _error: &str, _run_id: Uuid) { ... } fn on_tool_start(&self, _tool: &str, _args: &Value, _run_id: Uuid) { ... } fn on_tool_end(&self, _tool: &str, _result: &Value, _run_id: Uuid) { ... } fn on_tool_error(&self, _tool: &str, _error: &str, _run_id: Uuid) { ... } fn on_node_start(&self, _node: &str, _step: u64, _run_id: Uuid) { ... } fn on_node_end( &self, _node: &str, _step: u64, _output: &Value, _run_id: Uuid, ) { ... } fn on_checkpoint(&self, _step: u64, _run_id: Uuid) { ... } fn on_custom(&self, _kind: &str, _payload: &Value, _run_id: Uuid) { ... } fn name(&self) -> &str { ... }
}
Expand description

Typed lifecycle callbacks. All methods have default no-op impls; implement only what you need.

Provided Methods§

Source

fn on_chain_start(&self, _runnable: &str, _input: &Value, _run_id: Uuid)

A Runnable (chain / graph) started.

Source

fn on_chain_end(&self, _runnable: &str, _output: &Value, _run_id: Uuid)

A Runnable finished successfully.

Source

fn on_chain_error(&self, _runnable: &str, _error: &str, _run_id: Uuid)

A Runnable errored.

Source

fn on_llm_start(&self, _model: &str, _prompt: &Value, _run_id: Uuid)

LLM / chat-model invocation started.

Source

fn on_llm_token(&self, _token: &str, _run_id: Uuid)

LLM emitted a streamed token.

Source

fn on_llm_end(&self, _model: &str, _output: &Value, _run_id: Uuid)

LLM finished a generation.

Source

fn on_llm_error(&self, _model: &str, _error: &str, _run_id: Uuid)

LLM errored.

Source

fn on_tool_start(&self, _tool: &str, _args: &Value, _run_id: Uuid)

Tool execution started.

Source

fn on_tool_end(&self, _tool: &str, _result: &Value, _run_id: Uuid)

Tool execution finished.

Source

fn on_tool_error(&self, _tool: &str, _error: &str, _run_id: Uuid)

Tool errored.

Source

fn on_node_start(&self, _node: &str, _step: u64, _run_id: Uuid)

Graph node started.

Source

fn on_node_end(&self, _node: &str, _step: u64, _output: &Value, _run_id: Uuid)

Graph node finished.

Source

fn on_checkpoint(&self, _step: u64, _run_id: Uuid)

Graph engine persisted a checkpoint.

Source

fn on_custom(&self, _kind: &str, _payload: &Value, _run_id: Uuid)

Custom node-emitted event.

Source

fn name(&self) -> &str

Friendly name for diagnostics.

Implementations on Foreign Types§

Source§

impl CallbackHandler for Arc<dyn CallbackHandler>

Source§

fn on_chain_start(&self, runnable: &str, input: &Value, run_id: Uuid)

Source§

fn on_chain_end(&self, runnable: &str, output: &Value, run_id: Uuid)

Source§

fn on_chain_error(&self, runnable: &str, error: &str, run_id: Uuid)

Source§

fn on_llm_start(&self, model: &str, prompt: &Value, run_id: Uuid)

Source§

fn on_llm_token(&self, token: &str, run_id: Uuid)

Source§

fn on_llm_end(&self, model: &str, output: &Value, run_id: Uuid)

Source§

fn on_llm_error(&self, model: &str, error: &str, run_id: Uuid)

Source§

fn on_tool_start(&self, tool: &str, args: &Value, run_id: Uuid)

Source§

fn on_tool_end(&self, tool: &str, result: &Value, run_id: Uuid)

Source§

fn on_tool_error(&self, tool: &str, error: &str, run_id: Uuid)

Source§

fn on_node_start(&self, node: &str, step: u64, run_id: Uuid)

Source§

fn on_node_end(&self, node: &str, step: u64, output: &Value, run_id: Uuid)

Source§

fn on_checkpoint(&self, step: u64, run_id: Uuid)

Source§

fn on_custom(&self, kind: &str, payload: &Value, run_id: Uuid)

Source§

fn name(&self) -> &str

Implementors§