From notebook to shipped app
In Lesson 04, you built a ChatSession in a notebook. It worked. You fed it prompts, it remembered context, you saw the magic. But your friend can't run Jupyter. Non-technical people need a UI.
Streamlit bridges that gap: a Python framework that turns scripts into interactive web apps in minutes. No HTML, no JavaScript, no server setup. You write Python; Streamlit handles the UI and runs it in a browser.
By the end of this lesson, your agent will have a professional chat UI, persist memory across browser reloads, and run on a free cloud server anyone can visit.
Streamlit in 5 minutes
Three commands get you started:
A minimal Streamlit app:
Building a chat UI around ChatSession
Streamlit has chat-specific widgets: `st.chat_input()` for the user's message box, and `st.chat_message()` to display messages as cards. Here's a working chat app that uses your ChatSession from Lesson 04:
A user opens the app in their browser. They see a chat interface. They type "What's my balance?" The agent responds. On the next message, the agent still remembers the account number from the first turn. All messages appear in a clean chat log.
Session state: memory persists across reruns
The magic of `st.session_state` is that it remembers data across page reloads. Every time the user sends a message, Streamlit reruns your script. Without session state, the ChatSession would reset. With it, the same ChatSession object stays in memory for that browser session.
Display tool calls: show work-in-progress
When an agent calls a tool (search, database query), users want to see it happening. Streamlit's status containers let you show "🔧 Searching for HDFCBANK.NS..." as the agent works.
Streaming responses: watch tokens appear
Instead of waiting for the full response, users enjoy watching tokens stream in. Streamlit's `st.write_stream()` shows words as they arrive from the LLM.
Deploy free to Streamlit Cloud
Streamlit Cloud is free, GitHub-connected, and handles all infrastructure. Three steps:
Step 1: Push code to GitHub
Create a repo with your `app.py` and a `requirements.txt`:
Step 2: Connect your GitHub repo
Go to streamlit.io/cloud, sign in with GitHub, select your repo, and click "Deploy". Streamlit runs `pip install -r requirements.txt` and starts your app.
Step 3: Your app is live
Streamlit assigns you a URL like https://yourname-agentwiki.streamlit.app. Share it. Your agent is now live on the internet.
Secrets: Ollama endpoint, API keys
Never hardcode API keys or endpoints in your code. Streamlit has a secrets file.
Locally: Create `.streamlit/secrets.toml`:
In your app, access via `st.secrets`:
On Streamlit Cloud: Go to your app's settings, paste secrets in the UI, and Streamlit injects them at runtime. Your code reads them the same way: `st.secrets["key"]`.
Making it presentable: portfolio-ready polish
This is a demo of your work. Polish it. Add a logo, description, and professionalism.
Task: Create a Streamlit app for a Jumia Kenya customer support bot. Include:
1. Chat interface with st.chat_input
2. Model picker in sidebar (llama3.2, mistral)
3. Temperature slider (0.0–2.0)
4. Reset button
5. At least one message in chat history showing order context
Run locally with `streamlit run app.py`.
Hint: Combine the chat UI code from Section 3 with sidebar controls from Section 5. Initialize st.session_state with a ChatSession. For the system prompt, use something like "You are Aisha, Jumia Kenya support agent. Help with orders and refunds."
How production AI systems use this
Every major AI company (OpenAI, Anthropic, Google) runs Streamlit instances, Flask apps, or custom UIs on top of their LLMs. The pattern is identical: a web framework (Streamlit, React, Flutter) talks to an LLM backend (locally or via API), manages conversation state, and streams responses. Streamlit is the fastest path from "working agent" to "shipped product"—which is why startups use it to demo to investors.
Test your knowledge
Your agent is live.
Now build the next one.
Join the Best AI Program: The AI-Era Agentic Engineer — 5 months, fully online, with placement assistance. Week 1 is free.
Explore The AI-Era Agentic Engineer →