langchain.callbacks.streamlit.streamlit_callback_handler.StreamlitCallbackHandler¶
class langchain.callbacks.streamlit.streamlit_callback_handler.StreamlitCallbackHandler(parent_container: DeltaGenerator, *, max_thought_containers: int = 4, expand_new_thoughts: bool = True, collapse_completed_thoughts: bool = True, thought_labeler: Optional[LLMThoughtLabeler] = None)[source]¶
A callback handler that writes to a Streamlit app.
Create a StreamlitCallbackHandler instance.
Parameters
parent_container – The st.container that will contain all the Streamlit elements that the
Handler creates.
max_thought_containers – The max number of completed LLM thought containers to show at once. When
this threshold is reached, a new thought will cause the oldest thoughts to
be collapsed into a “History” expander. Defaults to 4.
expand_new_thoughts – Each LLM “thought” gets its own st.expander. This param controls whether
that expander is expanded by default. Defaults to True.
collapse_completed_thoughts – If True, LLM thought expanders will be collapsed when completed.
Defaults to True.
thought_labeler – An optional custom LLMThoughtLabeler instance. If unspecified, the handler
will use the default thought labeling logic. Defaults to None.
Attributes
ignore_agent
Whether to ignore agent callbacks.
ignore_chain
Whether to ignore chain callbacks.
ignore_chat_model
Whether to ignore chat model callbacks.
ignore_llm
Whether to ignore LLM callbacks.
ignore_retriever
Whether to ignore retriever callbacks.
ignore_retry
Whether to ignore retry callbacks.
raise_error
run_inline
Methods
__init__(parent_container, *[, ...])
Create a StreamlitCallbackHandler instance.
on_agent_action(action[, color])
Run on agent action.