Skip to content

brvboas/nicegui-chatbot-with-persistent-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chatbot NiceGUI

A multi-session chatbot web application built with Python. I created this project based on Nicegui chatbot implementation as a prototype to have the following technologies working together:

  • NiceGUI for a responsive, interactive web UI
  • LangChain and langchain_openai for LLM integration (OpenAI GPT-4o)
  • Persistent chat history and multi-chat session management
  • AI-generated chat titles for each conversation
  • Markdown-formatted answers (supports code, links, etc.)

This chatbot is good for study, learning, and experimenting with conversational AI and prompt engineering.

Features

  • Simple chat interface with NiceGUI
  • Multi-chat support: switch between previous conversations
  • Persistent chat history (saved to disk)
  • AI-generated short titles for each chat
  • Markdown rendering for both user and AI messages
  • Secure API key loading from .env
  • Modular, maintainable codebase

Installation

  1. Clone this repository.
  2. Install dependencies:
    pip install -r requirements.txt
  3. Create a .env file in the project root with your OpenAI API key:
    OPENAI_API_KEY=your_openai_api_key_here
  4. Run the app:
    python main.py

Usage

  • Start a new chat or select a previous chat from the sidebar.
  • Type your message and press Enter.
  • The conversation is saved automatically, and you can return to any previous chat.
  • Each chat is given a short, AI-generated title for easy identification.
  • All messages support markdown formatting.

Project Structure

  • main.py — Entry point, sets up the NiceGUI page and launches the app
  • chat_app.py — Contains the ChatApp class with all UI and logic
  • chat_storage.py — Handles persistent chat storage and retrieval
  • .env — Your OpenAI API key (not included in git)

Being Honest

Being honest, the docstrings in this project were generated with a little help from AI. 😄

Author

Bruno Villas Boas

License

MIT

About

This project is a multi-session chatbot web app built with Python, NiceGUI, and OpenAI's GPT models. It features persistent chat history, AI-generated chat titles, markdown support, and an intuitive interface for managing and revisiting conversations. Ideal for learning, prototyping, and experimenting with conversational AI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages