MutableExpander#

class langchain_community.callbacks.streamlit.mutable_expander.MutableExpander(parent_container: DeltaGenerator, label: str, expanded: bool)[source]#

Streamlit expander that can be renamed and dynamically expanded/collapsed.

Create a new MutableExpander.

Parameters:
  • parent_container (DeltaGenerator) –

    The st.container that the expander will be created inside.

    The expander transparently deletes and recreates its underlying st.expander instance when its label changes, and it uses parent_container to ensure it recreates this underlying expander in the same location onscreen.

  • label (str) – The expander’s initial label.

  • expanded (bool) – The expander’s initial expanded value.

Attributes

expanded

True if the expander was created with expanded=True.

label

Expander's label string.

Methods

__init__(parent_container, label, expanded)

Create a new MutableExpander.

append_copy(other)

Append a copy of another MutableExpander's children to this MutableExpander.

clear()

Remove the container and its contents entirely.

exception(exception, *[, index])

Add an Exception element to the container and return its index.

markdown(body[, unsafe_allow_html, help, index])

Add a Markdown element to the container and return its index.

update(*[, new_label, new_expanded])

Change the expander's label and expanded state

__init__(parent_container: DeltaGenerator, label: str, expanded: bool)[source]#

Create a new MutableExpander.

Parameters:
  • parent_container (DeltaGenerator) –

    The st.container that the expander will be created inside.

    The expander transparently deletes and recreates its underlying st.expander instance when its label changes, and it uses parent_container to ensure it recreates this underlying expander in the same location onscreen.

  • label (str) – The expander’s initial label.

  • expanded (bool) – The expander’s initial expanded value.

append_copy(other: MutableExpander) → None[source]#

Append a copy of another MutableExpander’s children to this MutableExpander.

Parameters:

other (MutableExpander)

Return type:

None

clear() → None[source]#

Remove the container and its contents entirely. A cleared container can’t be reused.

Return type:

None

exception(exception: BaseException, *, index: int | None = None) → int[source]#

Add an Exception element to the container and return its index.

Parameters:
  • exception (BaseException)

  • index (int | None)

Return type:

int

markdown(body: SupportsStr, unsafe_allow_html: bool = False, *, help: str | None = None, index: int | None = None) → int[source]#

Add a Markdown element to the container and return its index.

Parameters:
  • body (SupportsStr)

  • unsafe_allow_html (bool)

  • help (Optional[str])

  • index (Optional[int])

Return type:

int

update(*, new_label: str | None = None, new_expanded: bool | None = None) → None[source]#

Change the expander’s label and expanded state

Parameters:
  • new_label (str | None)

  • new_expanded (bool | None)

Return type:

None