a
    agO                     @  sl   d dl mZ d dlmZmZ d dlmZ erDd dlmZ d dl	m
Z
 ddddd	d
ddddddddZdS )    )annotations)TYPE_CHECKINGOptional)BaseCallbackHandler)LLMThoughtLabeler)DeltaGenerator   TNmax_thought_containersexpand_new_thoughtscollapse_completed_thoughtsthought_labelerr   intboolzOptional[LLMThoughtLabeler]r   )parent_containerr
   r   r   r   returnc                C  sv   z ddl m} || ||||dW S  typ   zddlm} W n tyX   tdY n0 || ||||d Y S 0 dS )ab  Callback Handler that writes to a Streamlit app.

    This CallbackHandler is geared towards
    use with a LangChain Agent; it displays the Agent's LLM and tool-usage "thoughts"
    inside a series of Streamlit expanders.

    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.

    Returns
    -------
    A new StreamlitCallbackHandler instance.

    Note that this is an "auto-updating" API: if the installed version of Streamlit
    has a more recent StreamlitCallbackHandler implementation, an instance of that class
    will be used.

    r   )StreamlitCallbackHandlerr	   zoTo use the StreamlitCallbackHandler, please install langchain-community with `pip install langchain-community`.N)Zstreamlit.external.langchainr   ImportErrorZBlangchain_community.callbacks.streamlit.streamlit_callback_handler)r   r
   r   r   r   r   Z!_InternalStreamlitCallbackHandler r   t/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain/callbacks/streamlit/__init__.pyr      s.    -
r   )
__future__r   typingr   r   Zlangchain_core.callbacks.baser   Zlangchain_community.callbacksr   Zstreamlit.delta_generatorr   r   r   r   r   r   <module>   s   