https://github.com/garbii1/llm-application-chatbot
๐ค A simple AI chatbot built with Python, Hugging Face, and Flask. Powered by an open-source LLM and includes both a CLI and a web interface.
https://github.com/garbii1/llm-application-chatbot
ai beginner-friendly chatbot cli flask html-css-javascript hugging-face huggingface llm nlp open-source python transformers tutorial web-interface
Last synced: 9 months ago
JSON representation
๐ค A simple AI chatbot built with Python, Hugging Face, and Flask. Powered by an open-source LLM and includes both a CLI and a web interface.
- Host: GitHub
- URL: https://github.com/garbii1/llm-application-chatbot
- Owner: Garbii1
- Created: 2025-06-11T20:56:04.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-06-11T21:13:00.000Z (10 months ago)
- Last Synced: 2025-06-11T22:34:53.555Z (10 months ago)
- Topics: ai, beginner-friendly, chatbot, cli, flask, html-css-javascript, hugging-face, huggingface, llm, nlp, open-source, python, transformers, tutorial, web-interface
- Language: CSS
- Homepage:
- Size: 279 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ค My Simple Chatbot with Python, Hugging Face, and Flask
This is a personal project where I explored building a chatbot using open-source Large Language Models (LLMs) from Hugging Face. My goal was to learn how to create both a command-line chatbot and a web-based chatbot application, and to document my process and key takeaways here.
---
## ๐ Project Overview
- Command-Line Chatbot (Python)
- Web Application Integration (Flask + JavaScript)
---
## ๐ฏ What I Learned
- The components of a chatbot: Transformer, LLM, Tokenizer
- How to use an open-source LLM from Hugging Face Hub
- Programming a simple chatbot in Python
- Setting up a Flask backend server
- Integrating the chatbot into a web application
---
# ๐ฆ Part 1: Building a Command-Line Chatbot
### 1.1. Prerequisites
- Python 3
- `pip` and `virtualenv`
### 1.2. Setup
```bash
pip3 install virtualenv
virtualenv my_env
source my_env/bin/activate
```
Install required libraries:
```bash
python3 -m pip install transformers==4.30.2 torch
```
### 1.3. Run the Chatbot
```bash
python3 chatbot.py
```
Type `exit` to end the chat.
---
# ๐ฉ Part 2: Integrating the Chatbot into a Web Application
### 2.1. Prerequisites
- Complete Part 1 setup
- `git` for cloning the front-end repository
### 2.2. Setup
Install Flask libraries:
```bash
python3 -m pip install flask flask_cors
```
> _Note: The lab specifies `transformers==4.38.2` and `torch==2.2.1` for the web app._
Clone the front-end template:
```bash
git clone https://github.com/ibm-developer-skills-network/LLM_application_chatbot
```
This creates a `LLM_application_chatbot` directory with `static` and `templates` subdirectories.
### 2.3. Configure the Front-End
Open `LLM_application_chatbot/static/script.js` and set the API endpoint URL:
```javascript
const CHATBOT_ENDPOINT = 'http://127.0.0.1:5000/chatbot';
```
> _If using a cloud IDE, use the public URL provided by your environment._
### 2.4. Running the Web Application
Navigate to the project directory and start the Flask server:
```bash
cd LLM_application_chatbot/
python3 app.py
```
Open your browser and go to [http://127.0.0.1:5000](http://127.0.0.1:5000) to chat with your bot!
---
## ๐งช Testing the Backend (Optional)
You can test the `/chatbot` endpoint directly with `curl` as described in the setup instructions.
---
## ๐ Resources
- [Hugging Face Transformers Documentation](https://huggingface.co/docs/transformers/index)
- [Flask Documentation](https://flask.palletsprojects.com/)
---