This is a simple chat application built with Flask, simulating a ChatGPT-like interface. It uses a local language model API to generate responses and stores chat history in an SQLite database.
LocalAI/
├── app.py
├── static/
│ ├── images/
│ │ ├── user-avatar.png
│ │ └── assistant-avatar.png
│ ├── styles.css
│ ├── script.js
│ └── admin.js
├── templates/
│ ├── index.html
│ └── admin.html
├── chat.db
Clone the repository
git clone https://github.com/CypherWang/localAI.git
cd localAI
Create a virtual environment and activate it
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Install the dependencies
pip install -r requirements.txt
Initialize the database
python -c "from app import init_db; init_db()"
Start the Flask server
python app.py
Access the application in your web browser
http://127.0.0.1:5000
http://127.0.0.1:5000/admin
/
: Home page, chat interface./chat
: Endpoint for sending and receiving chat messages./sessions
: Retrieve all chat sessions./history/<int:session_id>
: Retrieve chat history for a specific session./admin
: Admin page, view all chat history./admin/data
: Endpoint to get all chat history data./session
: Endpoint to create a new chat session./session/<int:session_id>
: Endpoint to update the name of a chat session.This project is licensed under the MIT License.
Contributions are welcome! Please open an issue or submit a pull request for any changes.