liveBook · Manning

Streamlit

As explained in Knowledge Graphs and LLMs in Action

Streamlit is an open-source Python framework for creating interactive web applications from data and machine-learning code.

Streamlit provides a Python-first interface for interactive applications built around data, machine-learning pipelines, and knowledge-graph investigation. It supplies chat interaction, visualization, automatic updates, and session state without requiring separate frontend and backend APIs. section 15.2

A Streamlit interface can support:

  • Chat-like questions and answers with persistent conversation history. section 15.2
  • Real-time pipeline feedback through session state, automatic updates, and temporary placeholders. section 15.2 section 15.2.2
  • Mixed outputs such as Markdown, tables, maps, graph visualizations, queries, and reasoning summaries. section 15.2.2

LangGraph question-answering interface

A user submits a question with st.chat_input. Streamlit displays the question, creates an assistant placeholder, sends the question and selected graph elements through LangGraph, and progressively renders updates, graphs, or maps while retaining the conversation state. section 15.2.2

Listing 15.14 Message history implementation
class MessageHistory:
    def __init__(self):
        self.messages = [{}]   #1

    def update(self, message, finalize=False):
        self.messages[-1].update(message)   #2
        if finalize:  #3
            self.messages.append({})

    @staticmethod
    def display_message(msg):  #4
        with st.chat_message("user"):
            st.markdown(msg["question"])
        with st.chat_message("assistant"):   #5
            if "query_reasoning" in msg:
                st.markdown(f"##### Reasoning\n\n**output type**:\
                              `{msg['output_type']}`\n\n\
                               {msg['query_reasoning']}")
            if "table" in msg:
                st.table(msg["table"])
            if "map" in msg:
                map_ = folium.Map()
                nodes_to_map(msg["map"], map_)   #6
                st_folium(map_)
            if "query" in msg:  #7
                with st.expander("Query...", expanded=False):
                    st.markdown(f"```cypher\n\n{msg['query']}\n```")
                    st.json(msg["query_message"])
            if "summary" in msg:
                st.markdown(f"##### Summary\n\n{msg['summary']}")
                with st.expander("extra...", expanded=False):
                    st.json({   #8
                        "summary_reason": msg["summary_reason"],
                        "summary_analisys": msg["summary_analisys"]
                    })
                    st.json(msg, expanded=False)   #9

    def display_messages(self):  #10
        for message in self.messages:
            if not message:
                continue
            self.display_message(message)

Inspect the MessageHistory implementation for progressive message updates, assistant rendering, tables, and maps. section 15.2.2

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Explains interface requirements and implementation patterns, but defers specialized production-interface concerns.
Examples
Uses chat input, MessageHistory, placeholders, Markdown, tables, maps, graph selections, and progressive pipeline responses.
What it assumes
Assumes a Python-based LangGraph pipeline and teaches interaction-state wiring through concrete handlers and message objects.
What you can do after
Build it from scratch as a Python interface for interactive pipeline testing and visualization.
How it connects
Connects LangGraph, knowledge graphs, chat interfaces, session state, and interactive visualization.

Also explained in

Compare how 9 books explain Streamlit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Knowledge Graphs and LLMs in Action. The section links point to the parts of the book it draws on.