Console/terminal demo of a retrieval chatbot built with the ChatterBot library, supporting Windows 11 and Ubuntu Linux 24.04. It is trained from yml conversation files (20 English and 18 Traditional Chinese) into a sqlite database, and then answers a question by finding the closest match in that database — this is retrieval, not generation, so every answer comes from the training corpus. You can ask one question per run or start an interactive chat loop. A trained database ships at model/database.sqlite3, so it works out of the box; retraining takes only a few seconds. After the initial setup everything runs offline, and no GPU is involved.

 

[Folder Structure]

  • CLAUDE.md / AGENT.md: program specification (identical content).
  • CHANGELOG.md: change log.
  • copyright.txt: copyright notice.
  • data/yml/english/ and data/yml/tchinese/: the training conversations, 38 yml files in total.
  • model/database.sqlite3: the trained database that ships with the project; step 3 regenerates it.
  • model/database_2020_original.sqlite3: the legacy 2020 database, which is incompatible with the modern ChatterBot and is kept for reference only.
  • tool/tools.py: shared helpers.
  • src/: the scripts, the launcher scripts and this document.
  • venv/: Python virtual environment, created by step 1.

[Prerequisites]

  • Operating system: Windows 11 or Ubuntu Linux 24.04.
  • Python 3 and pip.
  • An internet connection for step 1 only, which installs the packages and downloads the spaCy model. Everything afterwards runs offline.
  • No GPU required.

[Instructions]

Step 1: create the virtual environment

Delete the old venv/, create a fresh one, install src/requirements.txt (chatterbot and pyyaml) and then download the spaCy model en_core_web_sm. Aborts loudly if any of these fails. This is the only step that needs the internet.

 

Windows 11: src\01_venv_create.bat

Ubuntu 24.04: bash src/01_venv_create.sh

 

Step 2: activate the virtual environment

Activate the venv you just created. On Linux, source it so the environment variables apply to the current shell.

 

Windows 11: src\02_venv_activate.bat

Ubuntu 24.04: source src/02_venv_activate.sh

 

Step 3: ask one question

Ask a single question and print the answer. The default question is "What is ORAI?".

 

Windows 11: src\04_inference.bat

Ubuntu 24.04: bash src/04_inference.sh

Your own question:

bash src/04_inference.sh --input "How are you?"

 

Step 4: chat interactively

Start an interactive chat loop and keep asking questions at the prompt. Press Ctrl+C to stop.

 

Windows 11: src\05_inference_continuously.bat

Ubuntu 24.04: bash src/05_inference_continuously.sh

 

Step 5: retrain the database (optional)

Rebuild model/database.sqlite3 from every yml file under data/yml. It takes only a few seconds. Run this after you add or edit conversations.

 

Windows 11: src\03_train.bat

Ubuntu 24.04: bash src/03_train.sh

 

Step 6: clear the virtual environment (optional)

Delete the venv/ folder to free disk space when you no longer need it.

 

Windows 11: src\99_venv_clear.bat

Ubuntu 24.04: bash src/99_venv_clear.sh

 

[Python Entry Points]

  • src/train.py: [--yml data/yml] [--database model/database.sqlite3]. Trains a fresh database from every yml file under the given folder.
  • src/inference.py: [--input "What is ORAI?"] [--database model/database.sqlite3]. Prints the best-match answer.
  • src/inference_continuously.py: [--database model/database.sqlite3]. Runs the interactive loop, where you type at the prompt.

[Usage Notes]

  • The original 2020 database was trained by ChatterBot 1.0, whose search index the modern library cannot read, so it returns wrong answers under ChatterBot 1.2. It is kept only as model/database_2020_original.sqlite3. The shipped model/database.sqlite3 was retrained from the same yml corpus and answers correctly.
  • The Traditional Chinese corpus is tagged with the English spaCy model, as in the original notebooks, so Chinese questions only get approximate matches.
  • To teach the bot new conversations, add yml files under data/yml/ and run the training step again.

[References]

 

This SDK is built in AppForAI - AI Dev Tools.

 

Purchase license separately:  USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.