Chat-Bot-API is a robust FastAPI-based chatbot service designed to provide users with an interactive AI-powered chat experience. This project integrates Retrieval-Augmented Generation (RAG) with OpenAI models, allowing seamless interactions with documents and custom models. Additionally, the project incorporates the free-to-use LLAMA model, making advanced AI technology accessible to all.
The service is modular, scalable, and open source, aiming to deliver efficient AI-driven solutions to users while ensuring flexibility and extensibility.
The primary goal of Chat-Bot-API is to:
- Simplify AI model interaction: By integrating document retrieval and conversational AI.
- Enhance user engagement: With personalized chatbots for every user.
- Democratize AI access: Through open-source implementation and free-to-use models.
- Promote collaboration: By offering a customizable and modular codebase for contributors.
-
User Authentication:
- Token-based secure login and registration.
- Persistent session management.
-
Chatbot Interaction:
- Personalized chat experiences for users.
- Support for both OpenAI models and free LLAMA models.
- Integration of document-based queries via RAG.
-
Model Management:
- Upload custom models with metadata and visibility options.
- Delete and manage existing models.
-
Dynamic Chat History:
- Save, retrieve, and manage chat messages.
- Efficient handling of large conversations.
-
CORS Middleware:
- Configured for cross-origin resource sharing to enable broader API usage.
-
Open Source:
- Fully transparent and modifiable for developers and organizations.
- Python: Ensure you have Python 3.10 or above installed.
- MySQL: Set up a MySQL database.
- Git: Clone the repository.
-
Clone the Repository:
git clone https://github.com/UznetDev/Chat-Bot-API.git cd Chat-Bot-API -
Set Up a Virtual Environment:
python -m venv env source env/bin/activate # For Linux/Mac env\Scripts\activate # For Windows
-
Install Dependencies:
pip install -r requirements.txt
-
Configure the Environment Variables:
- Create a
.envfile in thedatadirectory and add:MYSQL_HOST=<Your MySQL Host> MYSQL_USER=<Your MySQL User> MYSQL_PASSWORD=<Your MySQL Password> MYSQL_DATABASE=<Your Database Name> REPLECATE_API=<Your Replicate API Key>
- Create a
-
Run the Application:
fastapi dev main.py
-
Access the API: Open
http://127.0.0.1:8000/docsin your browser for interactive API documentation.
-
User Workflow:
- Users authenticate using tokens.
- They can interact with chatbots linked to their accounts.
- Chatbots process user queries and retrieve AI-generated answers.
-
Model Integration:
- OpenAI models and LLAMA models are used for RAG and general conversational tasks.
- Users can upload custom models for tailored experiences.
-
Database Management:
- Stores user data, chat history, and model metadata in MySQL.
-
CORS Middleware:
- Enables seamless API access from different domains.
Chat-Bot-API/
│
├── data/ # Configuration and environment files
│ ├── config.py
│
├── db/ # Database connection and utility scripts
│ ├── database.py
│
├── models/ # Language model handling
│ ├── llm.py
│
├── routes/ # FastAPI route definitions
│ ├── auth.py
│ ├── promts.py
│ ├── user_page.py
│
├── functions/ # Utility functions
│ ├── functions.py
│
├── main.py # Entry point of the application
├── loader.py # Initialization of core components
├── requirements.txt # Python dependencies
├── README.md # Documentation (this file)
│
└── .env # Environment configuration file
Chat-Bot-API was developed to address the need for a flexible, scalable, and open-source chatbot service. By integrating RAG and open AI models, it provides users with a robust system for interacting with documents and conversational models. It aims to democratize AI technology by offering free-to-use models and enabling collaboration in the open-source community.
Contributions are welcome! Follow these steps to contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature-name
- Make changes and commit:
git commit -m "Added a new feature" - Push to your fork:
git push origin feature-name
- Create a pull request to the
mainbranch.
This project is licensed under the MIT License. See the LICENSE file for details.
If you have any questions or suggestions, please contact:
- Email: uznetdev@gmail.com
- GitHub Issues: Issues section
- GitHub Profile: UznetDev
- Telegram: UZNet_Dev
- Linkedin: Abdurakhmon Niyozaliev