Bharat ChatAI is an AI-powered chatbot application that integrates various AI models and document processing functionalities. This application allows users to chat with the AI using different models, upload and process documents, and retrieve information from URLs.
Clone the repository:
git clone https://github.com/itsmohitkumar/bharat-chatbot-groq.git
cd bharat-chatbot-groq
Create a virtual environment and activate it:
python -m venv env
source env/bin/activate # On Windows, use `envScriptsactivate`
Install the required packages:
pip install -r requirements.txt
Create a .env
file in the project root directory and add your API key:
GROQ_API_KEY=your_api_key_here
Run the Streamlit application:
streamlit run app.py
To containerize the Bharat ChatAI application using Docker, follow these steps:
Create a Dockerfile:
In the root directory of your project, create a Dockerfile
with the following content:
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Make port 8501 available to the world outside this container
EXPOSE 8501
# Define environment variable
ENV GROQ_API_KEY=your_api_key_here
# Run the application
CMD ["streamlit", "run", "app.py"]
Build the Docker image: Run the following command in the terminal to build your Docker image:
docker build -t bharat-chatai .
Run the Docker container: After the image is built, you can run the application in a container with:
docker run -p 8501:8501 bharat-chatai
The application will be accessible at http://localhost:8501
.
To deploy the Bharat ChatAI application on AWS EC2, follow these steps:
Launch an EC2 instance:
t2.micro
(free-tier eligible).Connect to the EC2 instance:
ssh -i "your-key.pem" [email protected]
Install Docker on the EC2 instance:
sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
Clone the Bharat ChatAI repository:
git clone https://github.com/itsmohitkumar/bharat-chatbot-groq.git
cd bharat-chatbot-groq
Build and run the Docker container:
sudo docker build -t bharat-chatai .
sudo docker run -p 80:8501 bharat-chatai
Access the application:
http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com
).The file structure of the project is as follows:
bharat-chatai/
├── src/
│ ├── __init__.py
│ ├── logger.py
│ ├── prompt.py
│ ├── bharatchat/
│ │ ├── __init__.py
│ │ └── chatbot.py
├── setup.py
├── app.py
src/__init__.py
: Initialization file for the src
package.src/logger.py
: Module for logging configuration.src/prompt.py
: Module for defining prompt templates.src/bharatchat/__init__.py
: Initialization file for the bharatchat
package.src/bharatchat/chatbot.py
: Main module for the chatbot logic.setup.py
: Setup script for the package.app.py
: Main application file for running the Streamlit interface.The Config
class handles the configuration of the application, including retrieving the API key and fetching available model options from the Groq API.
The DocumentProcessor
class processes documents from uploaded files or URLs, splits them into chunks, and stores them in a FAISS vector store. It also generates summaries of the processed documents.
The ChatHandler
class handles chat queries, displays chat history, and retrieves responses using the document vectors.
The ToolsAndAgentsInitializer
class initializes the tools and agents for the chat interface, including setting up the model and creating combined chains for document and query processing.
The BharatChatAI
class initializes the application, including embeddings, document processing, and chat handling. It also runs the Streamlit app interface.
The StreamlitInterface
class renders the Streamlit app interface, including initializing the sidebar and handling user selections.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or support, please contact:
Author: Mohit Kumar
Email: [email protected]