Skip to content

This project focuses on building a retrieval-augmented generation (RAG) layer for analysis on the Ethereum blockchain using Google BigQuery

License

Notifications You must be signed in to change notification settings

garyzava/bigq-ethereum-rag

Repository files navigation

BigQuery Chat with Ethereum

BigQuery Ethereum RAG System

A production-grade RAG (Retrieval-Augmented Generation) system for querying Ethereum blockchain data using natural language, built entirely with BigQuery ML and Google APIs.

📄 Read the Technical Write-up - A comprehensive guide on building RAG systems using only SQL and Google APIs.

Prerequisites

This guide uses the Application Default Credentials (ADC) method.

  1. Set up a Google Cloud project

  2. Install the gcloud CLI

Requirements

  1. Environment variables
    Create a .env file with your project and location settings.

    • Recommended: use US as the location since public datasets are in the US region (this avoids cross-regional issues).
    • Use .env.example as a template.
  2. Authenticate with Google Cloud
    Run the following commands in your terminal:

    # Load environment variables
    set -a; source .env; set +a;
    
    # Authenticate
    gcloud auth application-default login
    
    # Set project
    gcloud config set project "$GOOGLE_CLOUD_PROJECT"
  3. Create a BigQuery connection

    bq mk --connection \
    --project_id="$GOOGLE_CLOUD_PROJECT" \
    --location="$GOOGLE_CLOUD_LOCATION" \
    --connection_type=CLOUD_RESOURCE \
    bq-llm-connection || true
    
    echo '---'
    
    bq show --connection \
    --project_id="$GOOGLE_CLOUD_PROJECT" \
    --location="$GOOGLE_CLOUD_LOCATION" \
    bq-llm-connection || true

    More on BigQuery connections here

Troubleshooting

If you encounter the following error while running BigQuery ML models:

The [email protected] does not have the permission to access or use the endpoint. Please grant the Vertex AI user role to the [email protected] following https://cloud.google.com/bigquery/docs/generate-text-tutorial#grant-permissions. If issue persists, contact [email protected] for help.

Grant the Vertex AI User role to the service account:

Structure

.
├── bigq_ai_app/
│   ├── core/
│   ├── utils/
│   └── ui.py
├── docs/
├── notebooks/
├── tests/
├── .env.example
├── .gitignore
├── app.py
├── pyproject.toml
└── README.md

How to run it

  1. Create a virtual environment:

    uv venv
  2. Activate the environment:

    source .venv/bin/activate
    # On Windows: .venv\Scripts\activate
  3. Install dependencies from your pyproject.toml:

    uv pip install -e .

    (The -e . installs your project in "editable" mode, which is great for development).

  4. Run the Gradio app:

    python app.py
    • Open http://127.0.0.1:7865
    • To expose a public link quickly: set share=True in launch()
    • To bind for containers/VMs: use server_name="0.0.0.0

About

This project focuses on building a retrieval-augmented generation (RAG) layer for analysis on the Ethereum blockchain using Google BigQuery

Resources

License

Stars

Watchers

Forks

Packages

No packages published