Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

How to hold all the status containers generated during retrieving? #40

@cehao628

Description

@cehao628

Thanks for your amazing work.

`class PrintRetrievalHandler(BaseCallbackHandler):
def init(self, container):
self.status = container.status("Context Retrieval")

def on_retriever_start(self, serialized: dict, query: str, **kwargs):
    self.status.write(f"**Question:** {query}")
    self.status.update(label=f"**Context Retrieval:** {query}")

def on_retriever_end(self, documents, **kwargs):
    for idx, doc in enumerate(documents):
        source = os.path.basename(doc.metadata["source"])
        self.status.write(f"**Document {idx} from {source}**")
        self.status.markdown(doc.page_content)
    self.status.update(state="complete")`

Here a status container is initialized. But the last one will disappear when starting a new retrieval. I know in streamlit, the session_state is used to store the objects, but I am new in streamlit, and I failed to implement.

Thanks for your attention. I appreciate it a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions