Skip to content

nikch97/handbook-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Setup Guide — Handbook Generator (Streamlit + Supabase + Gemini)

## Prerequisites
- Python 3.10+ installed
- A Google Gemini API key
- A Supabase project (Postgres) with pgvector enabled

---

## 1) Clone repo + create virtual environment
```bash
git clone
cd handbook-generator

python -m venv venv
# Windows:
venv\Scripts\activate
# Mac/Linux:
# source venv/bin/activate

2) Install dependencies

pip install -r requirements.txt

3) Supabase setup (one-time)

3.1 Create Supabase project

Create a project in Supabase, then copy:

  • Project URL
  • anon public key (from: Project Settings → API)

3.2 Enable pgvector

In Supabase → SQL Editor, run:

create extension if not exists vector;

3.3 Create documents table

(Embedding dimension is 3072 for gemini-embedding-001)

create table if not exists documents (
  id bigserial primary key,
  content text not null,
  metadata jsonb,
  embedding vector(3072)
);

3.4 Create similarity search function

create or replace function match_documents(
  query_embedding vector(3072),
  match_count int default 5
)
returns table(id bigint, content text, similarity float)
language sql stable
as $$
  select
    documents.id,
    documents.content,
    1 - (documents.embedding <=> query_embedding) as similarity
  from documents
  order by documents.embedding <=> query_embedding
  limit match_count;
$$;

4) Set environment variables

Windows (PowerShell)

setx GEMINI_API_KEY "YOUR_GEMINI_KEY"
setx SUPABASE_URL "YOUR_SUPABASE_PROJECT_URL"
setx SUPABASE_ANON_KEY "YOUR_SUPABASE_ANON_KEY"

Close and re-open your terminal after running setx.

Mac/Linux

export GEMINI_API_KEY="YOUR_GEMINI_KEY"
export SUPABASE_URL="YOUR_SUPABASE_PROJECT_URL"
export SUPABASE_ANON_KEY="YOUR_SUPABASE_ANON_KEY"

5) Run the app

streamlit run app.py

Open the local URL Streamlit prints (usually http://localhost:8501).


6) How to use (quick test)

  1. Upload a PDF
  2. Click Index this PDF in Supabase
  3. Ask a question in the chat input → verify contextual answer
  4. Enter a handbook topic → click Generate Handbook → verify output reaches 20,000+ words
  5. Download the generated handbook.md

Troubleshooting

  • If Gemini model name fails: use gemini-2.5-flash for generation.
  • If search returns nothing: make sure you indexed at least one PDF and the SQL function exists.
  • If Supabase insert fails: verify vector extension is enabled and embedding dimension is 3072.

If you want, paste your current `requirements.txt` here and I’ll clean it up (remove extras) so your setup guide matches exactly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages