π£οΈ Memory-Powered Chatbot (OpenRouter Edition) A minimalist Streamlit chat interface that wraps any free OpenRouter model and remembers the conversation for the entire browser session.
β¨ Features
Capability Details Conversational memory Stores messages in st.session_state and sends full history on every turn. Plug-and-play model Default mistralai/mistral-7b-instruct, but you can pick any free OpenRouter model from the sidebar. Adjustable creativity Temperature slider (0 β 1). Clear chat One-click reset keeps the system prompt but drops user/assistant turns. 100 % client-side UI Single Python file, no backend server needed. Proof-of-concept β no auth, persistence, or rate-limit handling. For production LLM chat (RAG, caching, SSO), contact drtomharty.com/bio.
π Add your OpenRouter API key Streamlit Cloud (recommended) Deploy the repo β β― β Edit secrets
Insert:
toml Copy Edit OPENROUTER_API_KEY = "sk-or-xxxxxxxxxxxxxxxx" Local development Create ~/.streamlit/secrets.toml:
toml Copy Edit OPENROUTER_API_KEY = "sk-or-xxxxxxxxxxxxxxxx" βor set an env-var:
bash Copy Edit export OPENROUTER_API_KEY=sk-or-xxxxxxxxxxxxxxxx π Quick start bash Copy Edit git clone https://github.com/yourname/openrouter-chatbot.git cd openrouter-chatbot-demo python -m venv venv && source venv/bin/activate # Win: venv\Scripts\activate pip install -r requirements.txt streamlit run chat_app.py Open http://localhost:8501 in your browser and start chatting.
βοΈ Zero-cost deployment on Streamlit Cloud Push the repo (public or private) to GitHub.
Go to streamlit.io/cloud β New App and select the repo/branch.
Add the OPENROUTER_API_KEY in Secrets.
Click Deploy β done!
ποΈ File structure Copy Edit chat_app.py β the entire app requirements.txt README.md β youβre here π οΈ Requirements shell Copy Edit streamlit>=1.32 requests (The models are served remotely by OpenRouter, so no heavy ML libs are required.)
π License CC0 β do whatever you like; attribution always appreciated.
π Acknowledgements OpenRouter β unified gateway to open LLMs
Streamlit β trivial web apps for Python
Enjoy the chat! π