Skip to main content

A Firebase Firestore RAG system that bridges natural language prompts with structured database queries. It converts user input into intelligent retrieval operations, allowing developers to interact with Firestore using plain English instead of writing queries manually.

Project description

Firebase RAG CLI (Firestore Natural Language Query Engine)

A Retrieval-Augmented Generation (RAG) system that allows you to query Firebase Firestore using natural language prompts, powered by Llama 3 via Ollama.

This tool converts plain English questions into structured Firestore queries and returns results directly from your database.


Features

  • Natural language querying for Firestore
  • Schema-aware query generation (required)
  • Powered by Llama 3 via Ollama
  • CLI-based initialization
  • Firebase Admin SDK integration
  • Simple local setup and execution

Prerequisites

1. Install Ollama and Llama 3

pip install ollama
ollama pull llama3

Make sure Ollama is installed and running on your system.


2. Firebase Setup

You must have a Firebase project and a service account key file.

Download your firebase-key.json from Firebase Console.


Installation

pip install pranavfirebase-rag

Initialization

After installing the package, run:

my-library init

This command will generate the following files in your project directory:

schema.json
firebase-key.json
rag.py

Configuration

1. schema.json (Required)

You must define your Firestore schema in this file.

Example:

{
  "users": {
    "Age": "int",
    "Name": "string",
    "Department": "string",
    "Salary": "int"
  }
}

This schema is mandatory. The RAG engine uses it to understand fields and build queries.


2. firebase-key.json

Paste your Firebase service account credentials into this file.

Example structure:

{
  "type": "service_account",
  "project_id": "your-project-id",
  "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
  "client_email": "your-client-email"
}

3. rag.py

This file is the main chatbot entry point.

Important:

  • Replace the default collection name (e.g. employees) with your Firestore collection name.
  • Do not modify internal logic unless required.

Usage

Run the chatbot:

python rag.py

You will enter an interactive terminal where you can query your database.


Example Queries

You can ask questions like:

  • Show all users above 25
  • List employees in AI department
  • Get users with salary greater than 100000
  • Find all names in the users collection
  • Show users younger than 30

How It Works

User Input → Llama 3 (Ollama) → Schema Parser → Query Builder → Firestore (Firebase Admin SDK) → Response Output


Architecture

User Input → Llama 3 (Ollama) → Schema Parser → Query Builder → Firestore → Response Output


Notes

  • Schema definition is required (not optional)
  • Firebase credentials must be valid
  • Ollama + Llama 3 must be installed and running before execution
  • Collection name must be correctly set in rag.py

Requirements

  • Python 3.8+
  • Firebase Admin SDK
  • Ollama
  • Llama 3 model

Author

Pranav Verma

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pranavfirebase_rag-0.1.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pranavfirebase_rag-0.1.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file pranavfirebase_rag-0.1.2.tar.gz.

File metadata

  • Download URL: pranavfirebase_rag-0.1.2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pranavfirebase_rag-0.1.2.tar.gz
Algorithm Hash digest
SHA256 659ade0bdc3a0e14f3026766c5a6cb820431612ee53655560f7bd4eb7fb1bdd4
MD5 1d3526fae61dc2d879c8c837f3a75e9a
BLAKE2b-256 044f201cdb0dd70362a57c29424330b068fe297d19b99dfe92947cccfa7470a2

See more details on using hashes here.

File details

Details for the file pranavfirebase_rag-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pranavfirebase_rag-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4d0a1ea218e1150f683c4f42438699f51d4218e40c008faef79ff5cac5f61e68
MD5 4d3f243bd3f6373cb9a99e644b23b4f3
BLAKE2b-256 947a4231a290721b10ed8c929c38cea5330f79d768680f14ab554bc28ebe7b5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page