{"id":1261,"date":"2023-10-30T19:52:41","date_gmt":"2023-10-30T19:52:41","guid":{"rendered":"https:\/\/justinmatters.co.uk\/wp\/?p=1261"},"modified":"2026-03-01T12:00:55","modified_gmt":"2026-03-01T12:00:55","slug":"streamlit-as-an-interface-for-large-language-models","status":"publish","type":"post","link":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/","title":{"rendered":"Streamlit as an Interface for Large Language Models"},"content":{"rendered":"<p>Streamlit is a very useful Python package for creating interactive web pages. It has <a href=\"https:\/\/docs.streamlit.io\/\">excellent documentation<\/a> and offers a quick and easy way to prototype web interfaces. Streamlit can easily provide sidebar controls, graphing and other neat features, but for the purposes of interacting with LLMs, the interesting thing is it implements a very easy to use web chat interface in just a few lines of code.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1266\" src=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit-700x601.png\" alt=\"\" width=\"700\" height=\"601\" srcset=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit-700x601.png 700w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit-300x258.png 300w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit-768x659.png 768w, https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit.png 1504w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p><a href=\"https:\/\/github.com\/JustinMatters\/SmallProjects\/blob\/main\/streamlit_llm_app.py\">An example of a simple Streamlit interface for the ChatGPT LLM can be found here<\/a>. To run it you will need to perform the following steps:<\/p>\n<ul>\n<li>get an API key from OpenAI at https:\/\/openai.com\/blog\/openai-api<\/li>\n<li>open a command window (assuming windows) and add your API key keyto create an environmental variable<\/li>\n<\/ul>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\nsetx OPENAI_API_KEY &amp;quot;&amp;lt;your-key&amp;gt;&amp;quot;\r\n\r\n<\/pre>\n<ul>\n<li>pip install the required packages to your python environment<\/li>\n<\/ul>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\npip install openai\r\n\r\npip install streamlit\r\n\r\n<\/pre>\n<ul>\n<li>you can then check that streamlit works by running<\/li>\n<\/ul>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\nstreamlit hello\r\n\r\n<\/pre>\n<ul>\n<li>Download the sample app&#8217;s python file from <a href=\"https:\/\/github.com\/JustinMatters\/SmallProjects\/blob\/main\/streamlit_llm_app.py\">here<\/a><\/li>\n<li>run the app from the command line (or conda command line if using conda for your python environment) using<\/li>\n<\/ul>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\nstreamlit run streamlit_llm_app.py\r\n\r\n<\/pre>\n<p>If everything has gone well your browser should open a window allowing you to chat with ChatGPT. Congratulations you are now using Streamlit as an interface for Large Language Models.<\/p>\n<p>So how is this an advantage over using the chat GPT website? Well because you are running via the API rather than the chat interface you can customise what is available in the interface. You can insert system prompts in between the chat prompts to aid in prompt engineering. You could potentially use libraries like Langchain to allow for richer interactions than simple chat. Basically running LLMs via Streamlit offers you the convenience of a web interface combined with the power of python to customise what is going on under the hood.<\/p>\n<p>Best of all Streamlit has built in tools for handling Pandas dataframes and graphing data\u00a0 so there is potential to perform a wide range of other data related tasks as well as LLM interaction and even to get the two to interact.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Streamlit is a very useful Python package for creating interactive web pages. It has excellent documentation and offers a quick and easy way to prototype&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[199,5],"tags":[134,137,14,143],"class_list":["post-1261","post","type-post","status-publish","format-standard","hentry","category-artificial-intelligence","category-problem-solving","tag-chatgpt","tag-llm","tag-python","tag-streamlit"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Streamlit as an Interface for Large Language Models - Justin&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Streamlit as an Interface for Large Language Models - Justin&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"Streamlit is a very useful Python package for creating interactive web pages. It has excellent documentation and offers a quick and easy way to prototype&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/\" \/>\n<meta property=\"og:site_name\" content=\"Justin&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-30T19:52:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-01T12:00:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit-700x601.png\" \/>\n<meta name=\"author\" content=\"justinmatters\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"justinmatters\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/\"},\"author\":{\"name\":\"justinmatters\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/#\\\/schema\\\/person\\\/7c3e0740e1fef74f705c19f175f6f321\"},\"headline\":\"Streamlit as an Interface for Large Language Models\",\"datePublished\":\"2023-10-30T19:52:41+00:00\",\"dateModified\":\"2026-03-01T12:00:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/\"},\"wordCount\":373,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/streamlit-700x601.png\",\"keywords\":[\"chatGPT\",\"LLM\",\"Python\",\"Streamlit\"],\"articleSection\":[\"Artificial Intelligence\",\"Problem Solving\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/\",\"url\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/\",\"name\":\"Streamlit as an Interface for Large Language Models - Justin&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/streamlit-700x601.png\",\"datePublished\":\"2023-10-30T19:52:41+00:00\",\"dateModified\":\"2026-03-01T12:00:55+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/#\\\/schema\\\/person\\\/7c3e0740e1fef74f705c19f175f6f321\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/#primaryimage\",\"url\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/streamlit.png\",\"contentUrl\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/streamlit.png\",\"width\":1504,\"height\":1291},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/streamlit-as-an-interface-for-large-language-models\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Streamlit as an Interface for Large Language Models\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/#website\",\"url\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/\",\"name\":\"Justin's Blog\",\"description\":\"Justin&#039;s Coding and Geek Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/#\\\/schema\\\/person\\\/7c3e0740e1fef74f705c19f175f6f321\",\"name\":\"justinmatters\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g\",\"caption\":\"justinmatters\"},\"description\":\"Data Scientist specialising in Python, PySpark, SQL and Machine Learning\",\"sameAs\":[\"https:\\\/\\\/justinmatters.co.uk\\\/wp\\\/\",\"https:\\\/\\\/uk.linkedin.com\\\/in\\\/justin-matters-edinburgh\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Streamlit as an Interface for Large Language Models - Justin&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/","og_locale":"en_US","og_type":"article","og_title":"Streamlit as an Interface for Large Language Models - Justin&#039;s Blog","og_description":"Streamlit is a very useful Python package for creating interactive web pages. It has excellent documentation and offers a quick and easy way to prototype&hellip;","og_url":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/","og_site_name":"Justin&#039;s Blog","article_published_time":"2023-10-30T19:52:41+00:00","article_modified_time":"2026-03-01T12:00:55+00:00","og_image":[{"url":"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit-700x601.png","type":"","width":"","height":""}],"author":"justinmatters","twitter_card":"summary_large_image","twitter_misc":{"Written by":"justinmatters","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/#article","isPartOf":{"@id":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/"},"author":{"name":"justinmatters","@id":"https:\/\/justinmatters.co.uk\/wp\/#\/schema\/person\/7c3e0740e1fef74f705c19f175f6f321"},"headline":"Streamlit as an Interface for Large Language Models","datePublished":"2023-10-30T19:52:41+00:00","dateModified":"2026-03-01T12:00:55+00:00","mainEntityOfPage":{"@id":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/"},"wordCount":373,"commentCount":1,"image":{"@id":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/#primaryimage"},"thumbnailUrl":"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit-700x601.png","keywords":["chatGPT","LLM","Python","Streamlit"],"articleSection":["Artificial Intelligence","Problem Solving"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/","url":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/","name":"Streamlit as an Interface for Large Language Models - Justin&#039;s Blog","isPartOf":{"@id":"https:\/\/justinmatters.co.uk\/wp\/#website"},"primaryImageOfPage":{"@id":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/#primaryimage"},"image":{"@id":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/#primaryimage"},"thumbnailUrl":"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit-700x601.png","datePublished":"2023-10-30T19:52:41+00:00","dateModified":"2026-03-01T12:00:55+00:00","author":{"@id":"https:\/\/justinmatters.co.uk\/wp\/#\/schema\/person\/7c3e0740e1fef74f705c19f175f6f321"},"breadcrumb":{"@id":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/#primaryimage","url":"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit.png","contentUrl":"https:\/\/justinmatters.co.uk\/wp\/wp-content\/uploads\/2023\/11\/streamlit.png","width":1504,"height":1291},{"@type":"BreadcrumbList","@id":"https:\/\/justinmatters.co.uk\/wp\/streamlit-as-an-interface-for-large-language-models\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/justinmatters.co.uk\/wp\/"},{"@type":"ListItem","position":2,"name":"Streamlit as an Interface for Large Language Models"}]},{"@type":"WebSite","@id":"https:\/\/justinmatters.co.uk\/wp\/#website","url":"https:\/\/justinmatters.co.uk\/wp\/","name":"Justin's Blog","description":"Justin&#039;s Coding and Geek Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/justinmatters.co.uk\/wp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/justinmatters.co.uk\/wp\/#\/schema\/person\/7c3e0740e1fef74f705c19f175f6f321","name":"justinmatters","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/27cf337940887c098b79716aa7025ce782bd51de3f6b07a9dcad710bbf576c59?s=96&d=mm&r=g","caption":"justinmatters"},"description":"Data Scientist specialising in Python, PySpark, SQL and Machine Learning","sameAs":["https:\/\/justinmatters.co.uk\/wp\/","https:\/\/uk.linkedin.com\/in\/justin-matters-edinburgh"]}]}},"_links":{"self":[{"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/posts\/1261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/comments?post=1261"}],"version-history":[{"count":7,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/posts\/1261\/revisions"}],"predecessor-version":[{"id":1671,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/posts\/1261\/revisions\/1671"}],"wp:attachment":[{"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/media?parent=1261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/categories?post=1261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/justinmatters.co.uk\/wp\/wp-json\/wp\/v2\/tags?post=1261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}