I have decided to see if I can code an interactive version of the previous chat app. I plan to try using a database for storing the chat history for each user and/or conversation topic. So, multiple users, though I don’t think at the same time just yet. And I think it should run in a web browser. But, I really don’t want to try and code something using Flask. Based on web searches/tutorials, I am going to try using Streamlit for the web interface.
I had thought about using Postgres for the database. but I think I will start with SQLite. Expect that will be significantly easier.
I believe this is going to be more work and code than I am currently thinking. But, what’s life without a challenge or two.
New Project Module
I am going to start a new project module, chatbot_2.py
. It will be in the same directory as the module for the previous post. Don’t yet know if there will be any other modules required. But I am thinking some of the database code should go in its own module. Perhaps the Streamlit stuff as well.
Tried to get started on this yesterday (as of the time of drafting this post); but, just couldn’t do so. Think I was feeling a little overwhelmed. So, going to start slow and hopefully easy.
Install Streamlit
I plan to start by playing around with Streamlit. So, as it is not in my current virtual environment, I will begin by installing that in my conda environment. (Took a fair bit of time for the installation to complete.)
(llm-3.13) PS R:\learn\ds_llm> conda list .*stream.*
# packages in environment at E:\appDev\Miniconda3\envs\llm-3.13:
#
# Name Version Build Channel
(llm-3.13) PS R:\learn\ds_llm> conda search streamlit
Loading channels: done
# Name Version Build Channel```
... ...
treamlit 1.41.1 py312haa95532_0 pkgs/main
streamlit 1.41.1 py39haa95532_0 pkgs/main
streamlit 1.41.1 pyhd8ed1ab_0 conda-forge
streamlit 1.41.1 pyhd8ed1ab_1 conda-forge
(llm-3.13) PS R:\learn\ds_llm> conda install conda-forge::streamlit
Retrieving notices: ...working... done
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: E:\appDev\Miniconda3\envs\llm-3.13
added / updated specs:
- conda-forge::streamlit
The following packages will be downloaded:
package | build
---------------------------|-----------------
_openmp_mutex-4.5 | 2_gnu 48 KB conda-forge
altair-5.0.1 | py313haa95532_0 553 KB
aws-c-auth-0.8.1 | hd11252f_0 101 KB conda-forge
aws-c-cal-0.8.1 | h099ea23_3 46 KB conda-forge
aws-c-common-0.10.6 | h2466b09_0 230 KB conda-forge
aws-c-compression-0.3.0 | h099ea23_5 22 KB conda-forge
aws-c-event-stream-0.5.0 | h85d8506_11 53 KB conda-forge
aws-c-http-0.9.2 | h3888f84_4 178 KB conda-forge
aws-c-io-0.15.3 | hc5a9e45_6 156 KB conda-forge
aws-c-mqtt-0.11.0 | h2c94728_12 183 KB conda-forge
aws-c-s3-0.7.9 | h6a47413_1 107 KB conda-forge
aws-c-sdkutils-0.2.2 | h099ea23_0 54 KB conda-forge
aws-checksums-0.2.2 | h099ea23_4 90 KB conda-forge
aws-crt-cpp-0.29.9 | he488853_2 256 KB conda-forge
aws-sdk-cpp-1.11.489 | h7d73209_0 2.9 MB conda-forge
blinker-1.9.0 | py313haa95532_0 24 KB
c-ares-1.34.4 | h2466b09_0 189 KB conda-forge
cachetools-5.5.1 | py313haa95532_0 36 KB
certifi-2024.12.14 | py313haa95532_0 160 KB
click-8.1.7 | py313haa95532_0 208 KB
freetype-2.12.1 | hdaf720e_2 498 KB conda-forge
gitdb-4.0.7 | pyhd3eb1b0_0 50 KB
gitpython-3.1.43 | py313haa95532_0 361 KB
jinja2-3.1.5 | py313haa95532_0 369 KB
jsonschema-4.23.0 | py313haa95532_0 213 KB
jsonschema-specifications-2023.7.1| py313haa95532_0 16 KB
krb5-1.21.3 | hdf4eb48_0 695 KB conda-forge
lcms2-2.16 | h67d730c_0 496 KB conda-forge
lerc-4.0.0 | h5da7b33_0 185 KB
libabseil-20240722.0 | cxx17_h4eb7d71_4 1.7 MB conda-forge
libarrow-19.0.0 | hf554d7f_8_cpu 5.1 MB conda-forge
libarrow-acero-19.0.0 | h7d8d6a5_8_cpu 440 KB conda-forge
libarrow-dataset-19.0.0 | h7d8d6a5_8_cpu 426 KB conda-forge
libarrow-substrait-19.0.0 | h3dbecdf_8_cpu 356 KB conda-forge
libbrotlicommon-1.1.0 | h2466b09_2 69 KB conda-forge
libbrotlidec-1.1.0 | h2466b09_2 32 KB conda-forge
libbrotlienc-1.1.0 | h2466b09_2 240 KB conda-forge
libcrc32c-1.1.2 | hd77b12b_0 24 KB
libcurl-8.11.1 | h88aaa65_0 341 KB conda-forge
libdeflate-1.22 | h5bf469e_0 180 KB
libevent-2.1.12 | h56d1f94_1 417 KB
libexpat-2.6.4 | he0c23c2_0 136 KB conda-forge
libgcc-14.2.0 | h1383e82_1 651 KB conda-forge
libgomp-14.2.0 | h1383e82_1 512 KB conda-forge
libgoogle-cloud-2.34.0 | h95c5cb2_0 14 KB conda-forge
libgoogle-cloud-storage-2.34.0| he5eb982_0 14 KB conda-forge
libgrpc-1.67.1 | h0ac93cb_1 16.5 MB conda-forge
libjpeg-turbo-3.0.3 | h827c3e9_0 911 KB
liblzma-5.6.3 | h2466b09_1 102 KB conda-forge
libparquet-19.0.0 | ha850022_8_cpu 805 KB conda-forge
libpng-1.6.46 | had7236b_0 348 KB conda-forge
libprotobuf-5.28.3 | h8309712_1 5.9 MB conda-forge
libre2-11-2024.07.02 | h4eb7d71_2 255 KB conda-forge
libsqlite-3.48.0 | h67fdade_1 876 KB conda-forge
libssh2-1.11.1 | he619c9f_0 285 KB conda-forge
libthrift-0.21.0 | hbe90ef8_0 619 KB conda-forge
libtiff-4.7.0 | hdefb170_2 957 KB conda-forge
libutf8proc-2.10.0 | hf9b99b7_0 83 KB conda-forge
libwebp-base-1.5.0 | h3b0e114_0 267 KB conda-forge
libwinpthread-12.0.0.r4.gg4f2fc60ca| h57928b3_9 35 KB conda-forge
libxcb-1.17.0 | h0e4246c_0 1.2 MB conda-forge
libzlib-1.3.1 | h2466b09_2 54 KB conda-forge
lz4-c-1.10.0 | h2466b09_1 137 KB conda-forge
markdown-it-py-2.2.0 | py313haa95532_1 160 KB
markupsafe-2.1.3 | py313h827c3e9_1 36 KB
mdurl-0.1.0 | py313haa95532_0 23 KB
openjpeg-2.5.2 | hae555c5_0 268 KB
orc-2.0.3 | haf104fe_2 881 KB conda-forge
pandas-2.2.3 | py313hf91d08e_1 13.6 MB conda-forge
pillow-10.4.0 | py313h24ec7aa_1 40.3 MB conda-forge
protobuf-5.28.3 | py313h5813708_0 449 KB conda-forge
pyarrow-19.0.0 | py313hfa70ccb_0 25 KB conda-forge
pyarrow-core-19.0.0 |py313he812468_0_cpu 3.3 MB conda-forge
pydeck-0.9.1 | py313haa95532_0 5.0 MB
pygments-2.15.1 | py313haa95532_1 1.8 MB
python-3.13.1 |h071d269_105_cp313 16.0 MB conda-forge
python-dateutil-2.9.0post0 | py313haa95532_2 307 KB
python-tzdata-2023.3 | pyhd3eb1b0_0 140 KB
pytz-2024.1 | py313haa95532_0 202 KB
re2-2024.07.02 | haf4117d_2 210 KB conda-forge
referencing-0.30.2 | py313haa95532_0 75 KB
rich-13.9.4 | py313haa95532_0 634 KB
rpds-py-0.22.3 | py313h636fa0f_0 250 KB
smmap-4.0.0 | pyhd3eb1b0_0 23 KB
snappy-1.2.1 | hcdb6601_0 108 KB
streamlit-1.41.1 | pyhd8ed1ab_1 7.1 MB conda-forge
tk-8.6.13 | h5226925_1 3.3 MB conda-forge
toolz-1.0.0 | py313haa95532_0 146 KB
tornado-6.4.2 | py313h827c3e9_0 834 KB
tzlocal-5.2 | py313haa95532_0 43 KB
watchdog-6.0.0 | py313hfa70ccb_0 164 KB conda-forge
xorg-libxau-1.0.12 | h0e40799_0 105 KB conda-forge
xorg-libxdmcp-1.1.5 | h0e40799_0 68 KB conda-forge
zstd-1.5.6 | h0ea2cb4_0 341 KB conda-forge
------------------------------------------------------------
Total: 143.8 MB
The following NEW packages will be INSTALLED:
_openmp_mutex conda-forge/win-64::_openmp_mutex-4.5-2_gnu
altair pkgs/main/win-64::altair-5.0.1-py313haa95532_0
aws-c-auth conda-forge/win-64::aws-c-auth-0.8.1-hd11252f_0
aws-c-cal conda-forge/win-64::aws-c-cal-0.8.1-h099ea23_3
aws-c-common conda-forge/win-64::aws-c-common-0.10.6-h2466b09_0
aws-c-compression conda-forge/win-64::aws-c-compression-0.3.0-h099ea23_5
aws-c-event-stream conda-forge/win-64::aws-c-event-stream-0.5.0-h85d8506_11
aws-c-http conda-forge/win-64::aws-c-http-0.9.2-h3888f84_4
aws-c-io conda-forge/win-64::aws-c-io-0.15.3-hc5a9e45_6
aws-c-mqtt conda-forge/win-64::aws-c-mqtt-0.11.0-h2c94728_12
aws-c-s3 conda-forge/win-64::aws-c-s3-0.7.9-h6a47413_1
aws-c-sdkutils conda-forge/win-64::aws-c-sdkutils-0.2.2-h099ea23_0
aws-checksums conda-forge/win-64::aws-checksums-0.2.2-h099ea23_4
aws-crt-cpp conda-forge/win-64::aws-crt-cpp-0.29.9-he488853_2
aws-sdk-cpp conda-forge/win-64::aws-sdk-cpp-1.11.489-h7d73209_0
blinker pkgs/main/win-64::blinker-1.9.0-py313haa95532_0
c-ares conda-forge/win-64::c-ares-1.34.4-h2466b09_0
cachetools pkgs/main/win-64::cachetools-5.5.1-py313haa95532_0
click pkgs/main/win-64::click-8.1.7-py313haa95532_0
freetype conda-forge/win-64::freetype-2.12.1-hdaf720e_2
gitdb pkgs/main/noarch::gitdb-4.0.7-pyhd3eb1b0_0
gitpython pkgs/main/win-64::gitpython-3.1.43-py313haa95532_0
jinja2 pkgs/main/win-64::jinja2-3.1.5-py313haa95532_0
jsonschema pkgs/main/win-64::jsonschema-4.23.0-py313haa95532_0
jsonschema-specif~ pkgs/main/win-64::jsonschema-specifications-2023.7.1-py313haa95532_0
krb5 conda-forge/win-64::krb5-1.21.3-hdf4eb48_0
lcms2 conda-forge/win-64::lcms2-2.16-h67d730c_0
lerc pkgs/main/win-64::lerc-4.0.0-h5da7b33_0
libabseil conda-forge/win-64::libabseil-20240722.0-cxx17_h4eb7d71_4
libarrow conda-forge/win-64::libarrow-19.0.0-hf554d7f_8_cpu
libarrow-acero conda-forge/win-64::libarrow-acero-19.0.0-h7d8d6a5_8_cpu
libarrow-dataset conda-forge/win-64::libarrow-dataset-19.0.0-h7d8d6a5_8_cpu
libarrow-substrait conda-forge/win-64::libarrow-substrait-19.0.0-h3dbecdf_8_cpu
libbrotlicommon conda-forge/win-64::libbrotlicommon-1.1.0-h2466b09_2
libbrotlidec conda-forge/win-64::libbrotlidec-1.1.0-h2466b09_2
libbrotlienc conda-forge/win-64::libbrotlienc-1.1.0-h2466b09_2
libcrc32c pkgs/main/win-64::libcrc32c-1.1.2-hd77b12b_0
libcurl conda-forge/win-64::libcurl-8.11.1-h88aaa65_0
libdeflate pkgs/main/win-64::libdeflate-1.22-h5bf469e_0
libevent pkgs/main/win-64::libevent-2.1.12-h56d1f94_1
libexpat conda-forge/win-64::libexpat-2.6.4-he0c23c2_0
libgcc conda-forge/win-64::libgcc-14.2.0-h1383e82_1
libgomp conda-forge/win-64::libgomp-14.2.0-h1383e82_1
libgoogle-cloud conda-forge/win-64::libgoogle-cloud-2.34.0-h95c5cb2_0
libgoogle-cloud-s~ conda-forge/win-64::libgoogle-cloud-storage-2.34.0-he5eb982_0
libgrpc conda-forge/win-64::libgrpc-1.67.1-h0ac93cb_1
libjpeg-turbo pkgs/main/win-64::libjpeg-turbo-3.0.3-h827c3e9_0
liblzma conda-forge/win-64::liblzma-5.6.3-h2466b09_1
libparquet conda-forge/win-64::libparquet-19.0.0-ha850022_8_cpu
libpng conda-forge/win-64::libpng-1.6.46-had7236b_0
libprotobuf conda-forge/win-64::libprotobuf-5.28.3-h8309712_1
libre2-11 conda-forge/win-64::libre2-11-2024.07.02-h4eb7d71_2
libsqlite conda-forge/win-64::libsqlite-3.48.0-h67fdade_1
libssh2 conda-forge/win-64::libssh2-1.11.1-he619c9f_0
libthrift conda-forge/win-64::libthrift-0.21.0-hbe90ef8_0
libtiff conda-forge/win-64::libtiff-4.7.0-hdefb170_2
libutf8proc conda-forge/win-64::libutf8proc-2.10.0-hf9b99b7_0
libwebp-base conda-forge/win-64::libwebp-base-1.5.0-h3b0e114_0
libwinpthread conda-forge/win-64::libwinpthread-12.0.0.r4.gg4f2fc60ca-h57928b3_9
libxcb conda-forge/win-64::libxcb-1.17.0-h0e4246c_0
libzlib conda-forge/win-64::libzlib-1.3.1-h2466b09_2
lz4-c conda-forge/win-64::lz4-c-1.10.0-h2466b09_1
markdown-it-py pkgs/main/win-64::markdown-it-py-2.2.0-py313haa95532_1
markupsafe pkgs/main/win-64::markupsafe-2.1.3-py313h827c3e9_1
mdurl pkgs/main/win-64::mdurl-0.1.0-py313haa95532_0
openjpeg pkgs/main/win-64::openjpeg-2.5.2-hae555c5_0
orc conda-forge/win-64::orc-2.0.3-haf104fe_2
pandas conda-forge/win-64::pandas-2.2.3-py313hf91d08e_1
pillow conda-forge/win-64::pillow-10.4.0-py313h24ec7aa_1
protobuf conda-forge/win-64::protobuf-5.28.3-py313h5813708_0
pthread-stubs pkgs/main/win-64::pthread-stubs-0.3-h3c9f919_1
pyarrow conda-forge/win-64::pyarrow-19.0.0-py313hfa70ccb_0
pyarrow-core conda-forge/win-64::pyarrow-core-19.0.0-py313he812468_0_cpu
pydeck pkgs/main/win-64::pydeck-0.9.1-py313haa95532_0
pygments pkgs/main/win-64::pygments-2.15.1-py313haa95532_1
python-dateutil pkgs/main/win-64::python-dateutil-2.9.0post0-py313haa95532_2
python-tzdata pkgs/main/noarch::python-tzdata-2023.3-pyhd3eb1b0_0
pytz pkgs/main/win-64::pytz-2024.1-py313haa95532_0
re2 conda-forge/win-64::re2-2024.07.02-haf4117d_2
referencing pkgs/main/win-64::referencing-0.30.2-py313haa95532_0
rich pkgs/main/win-64::rich-13.9.4-py313haa95532_0
rpds-py pkgs/main/win-64::rpds-py-0.22.3-py313h636fa0f_0
six pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_1
smmap pkgs/main/noarch::smmap-4.0.0-pyhd3eb1b0_0
snappy pkgs/main/win-64::snappy-1.2.1-hcdb6601_0
streamlit conda-forge/noarch::streamlit-1.41.1-pyhd8ed1ab_1
toml pkgs/main/noarch::toml-0.10.2-pyhd3eb1b0_0
toolz pkgs/main/win-64::toolz-1.0.0-py313haa95532_0
tornado pkgs/main/win-64::tornado-6.4.2-py313h827c3e9_0
tzlocal pkgs/main/win-64::tzlocal-5.2-py313haa95532_0
watchdog conda-forge/win-64::watchdog-6.0.0-py313hfa70ccb_0
xorg-libxau conda-forge/win-64::xorg-libxau-1.0.12-h0e40799_0
xorg-libxdmcp conda-forge/win-64::xorg-libxdmcp-1.1.5-h0e40799_0
zstd conda-forge/win-64::zstd-1.5.6-h0ea2cb4_0
The following packages will be REMOVED:
xz-5.4.6-h8cc25b3_1
zlib-1.2.13-h8cc25b3_1
The following packages will be UPDATED:
ca-certificates conda-forge::ca-certificates-2024.12.~ --> pkgs/main::ca-certificates-2024.12.31-haa95532_0
python pkgs/main::python-3.13.1-hadb2040_100~ --> conda-forge::python-3.13.1-h071d269_105_cp313
The following packages will be SUPERSEDED by a higher-priority channel:
certifi conda-forge/noarch::certifi-2024.12.1~ --> pkgs/main/win-64::certifi-2024.12.14-py313haa95532_0
tk pkgs/main::tk-8.6.14-h0416ee5_0 --> conda-forge::tk-8.6.13-h5226925_1
Proceed ([y]/n)? y
Downloading and Extracting Packages
xorg-libxdmcp-1.1.5 | 68 KB | ############################################################################ | 100%
snappy-1.2.1 | 108 KB | ############################################################################ | 100%
libwebp-base-1.5.0 | 267 KB | ############################################################################ | 100%
aws-c-cal-0.8.1 | 46 KB | ############################################################################ | 100%
xorg-libxau-1.0.12 | 105 KB | ############################################################################ | 100%
referencing-0.30.2 | 75 KB | ############################################################################ | 100%
tk-8.6.13 | 3.3 MB | ############################################################################ | 100%
toolz-1.0.0 | 146 KB | ############################################################################ | 100%
jinja2-3.1.5 | 369 KB | ############################################################################ | 100%
libgomp-14.2.0 | 512 KB | ############################################################################ | 100%
pytz-2024.1 | 202 KB | ############################################################################ | 100%
rpds-py-0.22.3 | 250 KB | ############################################################################ | 100%
zstd-1.5.6 | 341 KB | ############################################################################ | 100%
libgcc-14.2.0 | 651 KB | ############################################################################ | 100%
aws-c-mqtt-0.11.0 | 183 KB | ############################################################################ | 100%
re2-2024.07.02 | 210 KB | ############################################################################ | 100%
lcms2-2.16 | 496 KB | ############################################################################ | 100%
libwinpthread-12.0.0 | 35 KB | ############################################################################ | 100%
aws-c-event-stream-0 | 53 KB | ############################################################################ | 100%
orc-2.0.3 | 881 KB | ############################################################################ | 100%
libdeflate-1.22 | 180 KB | ############################################################################ | 100%
tzlocal-5.2 | 43 KB | ############################################################################ | 100%
freetype-2.12.1 | 498 KB | ############################################################################ | 100%
pydeck-0.9.1 | 5.0 MB | ############################################################################ | 100%
_openmp_mutex-4.5 | 48 KB | ############################################################################ | 100%
libprotobuf-5.28.3 | 5.9 MB | ############################################################################ | 100%
libabseil-20240722.0 | 1.7 MB | ############################################################################ | 100%
aws-checksums-0.2.2 | 90 KB | ############################################################################ | 100%
... (more hidden) ...```
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
I included the lengthy output above, as, I have to admit, allowing that installation to proceed seriously scared me.
And a quick test.
(llm-3.13) PS R:\learn\ds_llm> streamlit hello
Welcome to Streamlit. Check out our demo in your browser.
Local URL: http://localhost:8501
Network URL: http://192.168.1.11:8501
Ready to create your own Python apps super quickly?
Head over to https://docs.streamlit.io
May you create awesome apps!
And the the Streamlit welcome page, with demos, was loaded into a browser tab in a currently open Firefox window. I also ran my earlier chatbot.py
module to make sure the code still runs in the updated environment.
New Module
In chatbot_2.py
I copied over the base startup code from the previous project. Note that I have added the import for Streamlit.
# chatbot_2.py: simple chat bot
# ver 0.1.0: code an interactive chat app that can run in web browser
# and use a database for storing chat history for multiple users, 2025.01.31, rek
from typing import Annotated
from typing_extensions import TypedDict
import os, time
from dotenv import load_dotenv
from pathlib import Path
from langchain_mistralai.chat_models import ChatMistralAI
from langchain_core.messages import HumanMessage
from langgraph.checkpoint.memory import MemorySaver
from langgraph.graph import StateGraph, MessagesState, START
import streamlit as st
load_dotenv()
api_ky = os.getenv("MISTRAL_API_KEY")
model = ChatMistralAI(model="mistral-large-latest", api_key=api_ky)
Try Building a Simple Page Using Streamlit
I am going to more or less recreate the Streamlit hello page. I.E. sidebar, main content area. For now the content will just be junk, as I don’t really know how my bot will look or run at this point. But, I would like to test adding buttons, selections of one sort or another, text, etc.
I am loading the content for the introduction page from a file containing the markdown to generate the html. I won’t bother showing you the content. I am sure you will be able to sort it out.
... ...
def get_file_as_string(f_pth):
with open(f_pth, encoding="utf-8") as f_md:
return f_md.read()
def run_app():
return("Running the app…")
# Test streamlit
if st_tst:
do_slct = False
do_rd = True
# Title of the app
app_ttl = "# Langchain & Streamlit Demo:<br>LLM Chatbot"
# Render the readme markdown to the page as html using st.markdown.
f_pth = Path("./app_intro.md")
readme_text = st.markdown(get_file_as_string(f_pth), unsafe_allow_html=True)
# Once we have the dependencies, add a selector for the app mode on the sidebar.
st.sidebar.title("What to do")
if do_slct:
app_mode = st.sidebar.selectbox("Choose the app mode",
["Show instructions", "Show the source code", "Run the app"])
elif do_rd:
app_mode = st.sidebar.radio("Choose the app mode",
["Show instructions", "Show the source code", "Run the app"])
if app_mode == "Show instructions":
st.title("")
st.sidebar.success('To continue select "Run the app".')
elif app_mode == "Show the source code":
st.title("Streamlit App with Sidebar")
readme_text.empty()
st.code(get_file_as_string("chatbot_2.py"))
elif app_mode == "Run the app":
st.markdown(app_ttl, unsafe_allow_html=True)
readme_text.empty()
st.write(run_app())
Start the Streamlit app.
(llm-3.13) PS R:\learn\ds_llm> streamlit run chatbot_2.py
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8501
Network URL: http://192.168.1.11:8501
And this appeared in a browser tab.

And here’s the top of the page showing the app source code.

Let’s Get Simple Chat Working
I will use Streamlit’s form
and form_submit_button
components to get the user input query. Then model.invoke
to get the LLM’s response. And finally Streamlit’s text write method to ouput the appropriate portion of the LLM’s response.
... ...
elif app_mode == "Run the app":
st.markdown(app_ttl, unsafe_allow_html=True)
readme_text.empty()
with st.form("my_form", clear_on_submit=True):
u_inp = st.text_area(
"Enter text:",
placeholder="Say something to the LLM or ask a question",
key="llm_ask",
)
submitted = st.form_submit_button("Submit")
if submitted:
llm_said = model.invoke(u_inp)
st.write(llm_said.content)
if submitted:
with st.container(border=True) as cont_2:
# and just for fun
st.write(llm_said.response_metadata)
And, here’s the basic form displayed.

And, the LLM’s reply to my input of “What are the best practices for learning to code? Please be brief and limit your response to the top 5 items.” My input is no longer displayed in the form due to the parameter clear_on_submit=True
passed when instantiating the form. And, I haven’t yet got around to maintaining the chat history, so I didn’t have the input available in a chat history to show on screen. That is coming.

Done
Well not much in the way of a substantial learning opportunity. But a little bit of things new and, in my case, useable.
As I need to do more research on using a database for conversation history, I am going to call this post finished.
Next time I will start by adding simple in memory conversation history. Then go onto to using a database to store chat histories for future use.
References
- Streamlit fundamental concepts
- Streamlist API reference
- API reference / Layouts & containers / st.container
- LangChain Python API Reference > langchain-core: 0.3.33 > messages > AIMessage
- Streamlit Part 1: Write and Text Elements
- Streamlit Part 6: Mastering Layouts
- Build an LLM app using LangChain
- Create a ChatBot with OpenAI and Streamlit in Python