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








