Skip to content

GDG-IIITS/Build-with-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– RAG System with Multiple Retrievers

A powerful Retrieval-Augmented Generation (RAG) system built with FastAPI and Google's Gemini AI. Upload your documents and ask questions - the AI will answer based on your content!


πŸ“‹ Table of Contents


🎯 What is this project?

This is a RAG (Retrieval-Augmented Generation) chatbot that:

  • Lets you upload PDF or text files
  • Stores the content in a smart way (using embeddings)
  • Answers your questions based on the uploaded documents
  • Remembers your conversation history

βœ… Prerequisites

Before you begin, make sure you have:

  • Python 3.9 or higher installed on your computer
  • A Google Account (to get the Gemini API key)
  • Git (optional, for cloning the repo)

πŸ“₯ Installation

Step 1: Clone or Download the Repository

Option A: Using Git

git clone https://github.com/yeschirag/Build-with-AI-GDG
cd build-with-ai

Option B: Download ZIP

  • Click the green "Code" button on GitHub
  • Select "Download ZIP"
  • Extract the ZIP file to a folder on your computer

Step 2: Open Terminal/Command Prompt

Navigate to the project folder:

cd path/to/your/project/folder

Step 3: Create a Virtual Environment (Recommended)

On Windows:

python -m venv venv
venv\Scripts\activate

On Mac/Linux:

python3 -m venv venv
source venv/bin/activate

Step 4: Install Required Packages

Run this command to install all dependencies:

pip install -r requirements.txt

Wait for all packages to install. This may take a few minutes.


πŸ”‘ Getting Your Gemini API Key

Follow these simple steps to get your FREE Gemini API key from Google AI Studio:

Step 1: Go to Google AI Studio

Open your browser and go to: https://aistudio.google.com/

Step 2: Sign In

  • Click "Sign in" (top right corner)
  • Sign in with your Google Account

Step 3: Get Your API Key

  1. Once signed in, click on "Get API Key" in the left sidebar (or look for it on the main page)

  2. Click "Create API Key"

  3. If asked, select a Google Cloud project or create a new one (it's free!)

  4. Your API key will be generated and displayed on the screen

  5. IMPORTANT: Copy the API key and save it somewhere safe! It looks something like this:

    AIzaSyB1234567890abcdefghijklmnop
    

⚠️ Important Notes:

  • Keep your API key secret! Don't share it publicly or commit it to GitHub
  • The free tier gives you plenty of requests to learn and experiment
  • If you lose your key, you can always create a new one

βš™οΈ Setting Up Environment Variables

You need to create a .env file to store your API key securely.

Step 1: Create the .env File

In your project folder, create a new file named .env (just .env, no other name before it)

On Windows:

  • Open Notepad
  • Save the file as .env in your project folder
  • Make sure to select "All Files" in the "Save as type" dropdown

On Mac/Linux:

touch .env

Step 2: Add Your API Key

Open the .env file and add this line:

GOOGLE_API_KEY=your_api_key_here

Replace your_api_key_here with your actual Gemini API key.

Example .env file:

GOOGLE_API_KEY=AIzaSyB1234567890abcdefghijklmnop

Step 3: Save the File

Save the .env file and close it.

πŸ“ Environment Variables Reference

Variable Name Description Required
GOOGLE_API_KEY Your Gemini API key from Google AI Studio βœ… Yes

πŸš€ Running the Application

Start the Server

Run this command in your terminal:

uvicorn main:app --reload

You should see output like this:

INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [xxxxx]
INFO:     Started server process [xxxxx]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

Open the Application

  1. Open your web browser
  2. Go to: http://127.0.0.1:8000 or http://localhost:8000
  3. You should see the RAG System interface!

To Stop the Server

Press CTRL + C in the terminal


πŸ’‘ How to Use

  1. Upload Documents: Click the upload button and select your PDF or text files
  2. Wait for Processing: The system will process and index your documents
  3. Ask Questions: Type your questions in the chat box
  4. Get AI Answers: The AI will respond based on your uploaded documents!

πŸ› Troubleshooting

"GOOGLE_API_KEY not set" error

  • Make sure your .env file is in the same folder as main.py
  • Check that the variable name is exactly GOOGLE_API_KEY
  • Restart the server after creating/editing the .env file

"Module not found" error

  • Make sure you ran pip install -r requirements.txt
  • Check that your virtual environment is activated

API Key not working

  • Verify you copied the entire key
  • Make sure there are no extra spaces
  • Try generating a new key from Google AI Studio

πŸ“ Project Structure

build-with-ai/
β”œβ”€β”€ main.py           # Backend server code
β”œβ”€β”€ index.html        # Frontend interface
β”œβ”€β”€ requirements.txt  # Python dependencies
β”œβ”€β”€ .env             # Your environment variables (create this!)
└── README.md        # This file

🀝 Need Help?

If you run into any issues:

  1. Double-check all the steps above
  2. Make sure all files are in the correct location
  3. Verify your API key is correct

πŸ“§ Contact

If you have any questions or face any errors, feel free to reach out:

Email: chirag.k24@iiits.in


Happy Learning! πŸŽ‰

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published