https://github.com/piyush-linux/llamaindex-rag-1
This project demonstrates how to create and interact with a query engine using LlamaIndex.
https://github.com/piyush-linux/llamaindex-rag-1
ai llama-index llama-projects llamaindex llamaindex-rag openai python3 vector
Last synced: 2 months ago
JSON representation
This project demonstrates how to create and interact with a query engine using LlamaIndex.
- Host: GitHub
- URL: https://github.com/piyush-linux/llamaindex-rag-1
- Owner: Piyush-linux
- License: mit
- Created: 2024-12-23T07:29:52.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-23T07:38:59.000Z (over 1 year ago)
- Last Synced: 2024-12-31T09:38:19.468Z (over 1 year ago)
- Topics: ai, llama-index, llama-projects, llamaindex, llamaindex-rag, openai, python3, vector
- Language: Jupyter Notebook
- Homepage:
- Size: 2.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π LlamaIndex Query Engine π
Welcome to the **LlamaIndex Query Engine** project! π
This project demonstrates how to create and interact with a **query engine** using `LlamaIndex`. It builds an index from documents stored in a specified directory and allows you to query the indexed data. If the index already exists, it loads the index from persistent storage, ensuring fast and efficient retrieval.
---
## π Features
- π **Document Indexing**: Loads documents from a specified directory and creates an index.
- πΎ **Persistent Storage**: Saves the index to disk for later use, avoiding unnecessary re-building.
- π **Query Engine**: After building or loading the index, you can perform queries with natural language.
- π§ **Customizable**: Easily adapt the project for different datasets and query requirements.
---
## π Requirements
Before you get started, make sure you have the following:
- π **Python 3.x**: Make sure you have Python 3 installed.
- π **Conda**: We use Conda environments to manage dependencies.
- π¦ **`llama_index`**: This package is used for indexing and querying data.
---
## βοΈ Setup
### 0. Scratch
```bash
conda create -p venv python==3.12 -y
conda activate ./venv
pip install -r requirements.txt
pip install ipykernel
```
### 1. Clone the repository
Start by cloning the project to your local machine:
```bash
git clone https://github.com/your-username/llamaindex-project.git
cd llamaindex-project
```
### 2. Create a Conda environment
To create a Conda environment and install the necessary dependencies, run:
```bash
conda env create -f environment.yml
```
This will create a new environment with all the required packages, including `llama_index`.
### 3. Activate the Conda environment
Once the environment is created, activate it using:
```bash
conda activate llamaindex-env
```
### 4. Install additional dependencies (if any)
If there are any extra dependencies, you can install them using:
```bash
pip install -r requirements.txt
```
This will install any missing packages that are required.
---
## πββοΈ Usage
### 1. Prepare your data
Place your documents in the `data` folder. The `SimpleDirectoryReader` will automatically load all documents from this directory to build the index.
### 2. Running the script
Once your data is prepared, run the script to either **create** or **load** the index, and then **perform a query**.
```bash
python main.py
```
### 3. Code Breakdown
- **Storage Check**: First, the script checks if the index already exists in the `./storage` directory.
- **Create or Load Index**: If the index doesn't exist, it loads documents from the `data` folder and creates a new index. If the index exists, it loads it from storage.
- **Querying**: Once the index is created or loaded, you can perform queries like `"list some essentials topics we learn?"`.
---
## π Directory Structure
Hereβs an overview of the project structure:
```
/llamaindex-project
β
βββ /data # Folder for storing your documents to index
βββ /storage # Directory for storing the index
βββ main.py # Main Python script for indexing and querying
βββ environment.yml # Conda environment configuration
βββ requirements.txt # List of additional Python dependencies
βββ README.md # This file
```
---
## β Troubleshooting
- **API Key Issues**: If you encounter issues with API keys (e.g., for OpenAI), ensure that your keys are correctly set in the `.env` file or environment variables.
- **Missing Dependencies**: Make sure the Conda environment is activated and all required dependencies are installed.
---
## π License
This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for more details.
---
## π€ Contributing
We welcome contributions! Feel free to fork the repository, make changes, and open pull requests. If you have suggestions or encounter issues, please open an issue in the repository.