StreamingStdOutCallbackHandler

Struct StreamingStdOutCallbackHandler 

Source
pub struct StreamingStdOutCallbackHandler;
Expand description

Callback handler for streaming. Only works with LLMs that support streaming.

This handler prints tokens to stdout as they are generated.

Implementations§

Source§

impl StreamingStdOutCallbackHandler

Source

pub fn new() -> Self

Create a new StreamingStdOutCallbackHandler.

Trait Implementations§

Source§

impl BaseCallbackHandler for StreamingStdOutCallbackHandler

Source§

fn name(&self) -> &str

Get a unique name for this handler. Note: This is a Rust-specific addition for debugging purposes.
Source§

fn raise_error(&self) -> bool

Whether to raise an error if an exception occurs.
Source§

fn run_inline(&self) -> bool

Whether to run the callback inline.
Source§

fn ignore_llm(&self) -> bool

Whether to ignore LLM callbacks.
Source§

fn ignore_retry(&self) -> bool

Whether to ignore retry callbacks.
Source§

fn ignore_chain(&self) -> bool

Whether to ignore chain callbacks.
Source§

fn ignore_agent(&self) -> bool

Whether to ignore agent callbacks.
Source§

fn ignore_retriever(&self) -> bool

Whether to ignore retriever callbacks.
Source§

fn ignore_chat_model(&self) -> bool

Whether to ignore chat model callbacks.
Source§

fn ignore_custom_event(&self) -> bool

Whether to ignore custom events.
Source§

impl CallbackManagerMixin for StreamingStdOutCallbackHandler

Source§

fn on_llm_start( &mut self, serialized: &HashMap<String, Value>, prompts: &[String], run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&[String]>, metadata: Option<&HashMap<String, Value>>, )

Run when LLM starts running.
Source§

fn on_chat_model_start( &mut self, serialized: &HashMap<String, Value>, messages: &[Vec<BaseMessage>], run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&[String]>, metadata: Option<&HashMap<String, Value>>, )

Run when a chat model starts running.
Source§

fn on_retriever_start( &mut self, serialized: &HashMap<String, Value>, query: &str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&[String]>, metadata: Option<&HashMap<String, Value>>, )

Run when the Retriever starts running.
Source§

fn on_chain_start( &mut self, serialized: &HashMap<String, Value>, inputs: &HashMap<String, Value>, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&[String]>, metadata: Option<&HashMap<String, Value>>, )

Run when a chain starts running.
Source§

fn on_tool_start( &mut self, serialized: &HashMap<String, Value>, input_str: &str, run_id: Uuid, parent_run_id: Option<Uuid>, tags: Option<&[String]>, metadata: Option<&HashMap<String, Value>>, inputs: Option<&HashMap<String, Value>>, )

Run when the tool starts running.
Source§

impl ChainManagerMixin for StreamingStdOutCallbackHandler

Source§

fn on_chain_end( &mut self, outputs: &HashMap<String, Value>, run_id: Uuid, parent_run_id: Option<Uuid>, )

Run when chain ends running.
Source§

fn on_chain_error( &mut self, error: &dyn Error, run_id: Uuid, parent_run_id: Option<Uuid>, )

Run when chain errors.
Source§

fn on_agent_action( &mut self, action: &Value, run_id: Uuid, parent_run_id: Option<Uuid>, color: Option<&str>, )

Run on agent action.
Source§

fn on_agent_finish( &mut self, finish: &Value, run_id: Uuid, parent_run_id: Option<Uuid>, color: Option<&str>, )

Run on the agent end.
Source§

impl Clone for StreamingStdOutCallbackHandler

Source§

fn clone(&self) -> StreamingStdOutCallbackHandler

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StreamingStdOutCallbackHandler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StreamingStdOutCallbackHandler

Source§

fn default() -> StreamingStdOutCallbackHandler

Returns the “default value” for a type. Read more
Source§

impl LLMManagerMixin for StreamingStdOutCallbackHandler

Source§

fn on_llm_new_token( &mut self, token: &str, _run_id: Uuid, _parent_run_id: Option<Uuid>, _chunk: Option<&Value>, )

Run on new output token. Only available when streaming is enabled.
Source§

fn on_llm_end( &mut self, response: &ChatResult, run_id: Uuid, parent_run_id: Option<Uuid>, )

Run when LLM ends running.
Source§

fn on_llm_error( &mut self, error: &dyn Error, run_id: Uuid, parent_run_id: Option<Uuid>, )

Run when LLM errors.
Source§

impl RetrieverManagerMixin for StreamingStdOutCallbackHandler

Source§

fn on_retriever_error( &mut self, error: &dyn Error, run_id: Uuid, parent_run_id: Option<Uuid>, )

Run when Retriever errors.
Source§

fn on_retriever_end( &mut self, documents: &[Value], run_id: Uuid, parent_run_id: Option<Uuid>, )

Run when Retriever ends running.
Source§

impl RunManagerMixin for StreamingStdOutCallbackHandler

Source§

fn on_text( &mut self, text: &str, run_id: Uuid, parent_run_id: Option<Uuid>, color: Option<&str>, end: &str, )

Run on an arbitrary text.
Source§

fn on_retry( &mut self, retry_state: &dyn Any, run_id: Uuid, parent_run_id: Option<Uuid>, )

Run on a retry event.
Source§

fn on_custom_event( &mut self, name: &str, data: &dyn Any, run_id: Uuid, tags: Option<&[String]>, metadata: Option<&HashMap<String, Value>>, )

Override to define a handler for a custom event.
Source§

impl ToolManagerMixin for StreamingStdOutCallbackHandler

Source§

fn on_tool_end( &mut self, output: &str, run_id: Uuid, parent_run_id: Option<Uuid>, color: Option<&str>, observation_prefix: Option<&str>, llm_prefix: Option<&str>, )

Run when the tool ends running.
Source§

fn on_tool_error( &mut self, error: &dyn Error, run_id: Uuid, parent_run_id: Option<Uuid>, )

Run when tool errors.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more