Spaces:
Running
Running
Yuvraj Sarathe commited on
Commit Β·
675aa29
1
Parent(s): fa8f11a
Readme and .env.example updated with proper comments
Browse files- .env.example +115 -10
- README.md +24 -16
.env.example
CHANGED
|
@@ -1,30 +1,135 @@
|
|
| 1 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
SECRET_KEY=change-me-in-production
|
| 3 |
-
DATABASE_URL=sqlite:///./data/app.db
|
| 4 |
|
| 5 |
# ββ Environment & CORS ββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
ENVIRONMENT=development
|
| 7 |
-
|
| 8 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:7860
|
| 10 |
|
| 11 |
-
# ββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
HF_TOKEN=your_huggingface_token_here
|
| 13 |
|
| 14 |
-
# ββ LLM
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# LLM_MODEL=mistralai/Mistral-7B-Instruct-v0.3
|
|
|
|
|
|
|
|
|
|
| 16 |
# LLM_TEMPERATURE=0.3
|
|
|
|
|
|
|
|
|
|
| 17 |
# LLM_MAX_NEW_TOKENS=1024
|
| 18 |
|
| 19 |
-
# ββ Embeddings (Optional β defaults shown)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# ββ RAG Config (Optional β defaults shown) βββββββββββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
# CHUNK_SIZE=1000
|
|
|
|
|
|
|
|
|
|
| 24 |
# CHUNK_OVERLAP=200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
# TOP_K_RETRIEVAL=10
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# TOP_K_RERANK=5
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
#
|
| 30 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Document AI Analyst β Environment Configuration
|
| 2 |
+
# Copy this file to backend/.env and fill in your values:
|
| 3 |
+
# cp .env.example backend/.env
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
# ββ Application Config ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 7 |
+
|
| 8 |
+
# Secret key for signing JWT tokens and Flask sessions.
|
| 9 |
+
# Generate one: python -c "import secrets; print(secrets.token_urlsafe(32))"
|
| 10 |
+
# Required
|
| 11 |
SECRET_KEY=change-me-in-production
|
|
|
|
| 12 |
|
| 13 |
# ββ Environment & CORS ββββββββββββββββββββββββββββββ
|
| 14 |
+
|
| 15 |
+
# Runtime environment. Set to "production" in production.
|
| 16 |
+
# In production, ALLOWED_ORIGINS must be set explicitly (CORS will reject all others).
|
| 17 |
+
# Optional β defaults to "development"
|
| 18 |
ENVIRONMENT=development
|
| 19 |
+
|
| 20 |
+
# Debug mode. Enables detailed error pages and auto-reload.
|
| 21 |
+
# Do NOT enable in production.
|
| 22 |
+
# Optional β defaults to False
|
| 23 |
+
# DEBUG=False
|
| 24 |
+
|
| 25 |
+
# Comma-separated list of allowed CORS origins.
|
| 26 |
+
# Only used when ENVIRONMENT=production. When empty or during development, all origins are allowed.
|
| 27 |
+
# Optional β defaults to "http://localhost:3000,http://localhost:7860"
|
| 28 |
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:7860
|
| 29 |
|
| 30 |
+
# ββ Database βββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 31 |
+
|
| 32 |
+
# SQLAlchemy database connection string.
|
| 33 |
+
# Default: SQLite stored at ./data/app.db
|
| 34 |
+
# For Postgres: postgresql+asyncpg://user:pass@host:5432/dbname
|
| 35 |
+
# Optional β defaults to sqlite:///./data/app.db
|
| 36 |
+
# DATABASE_URL=sqlite:///./data/app.db
|
| 37 |
+
|
| 38 |
+
# ββ Authentication ββββββββββββββββββββββββββββββββββββββββββ
|
| 39 |
+
|
| 40 |
+
# JWT signing algorithm. Leave as default unless you know what you're doing.
|
| 41 |
+
# Optional β defaults to "HS256"
|
| 42 |
+
# JWT_ALGORITHM=HS256
|
| 43 |
+
|
| 44 |
+
# JWT token expiry in hours. After this period, users must re-login.
|
| 45 |
+
# Optional β defaults to 72
|
| 46 |
+
# JWT_EXPIRY_HOURS=72
|
| 47 |
+
|
| 48 |
+
# ββ File Upload βββββββββββββββββββββββββββββββββββββββββββββ
|
| 49 |
+
|
| 50 |
+
# Directory where uploaded documents (PDFs, DOCXs, etc.) are stored.
|
| 51 |
+
# Optional β defaults to "./data/uploads"
|
| 52 |
+
# UPLOAD_DIR=./data/uploads
|
| 53 |
+
|
| 54 |
+
# Maximum upload file size in megabytes.
|
| 55 |
+
# Optional β defaults to 50
|
| 56 |
+
# MAX_FILE_SIZE_MB=50
|
| 57 |
+
|
| 58 |
+
# Comma-separated list of allowed file extensions for upload.
|
| 59 |
+
# Optional β defaults to "pdf,docx,txt,md"
|
| 60 |
+
# ALLOWED_EXTENSIONS=pdf,docx,txt,md
|
| 61 |
+
|
| 62 |
+
# ββ HuggingFace (Required for LLM inference) ββββββββββββββββ
|
| 63 |
+
|
| 64 |
+
# HuggingFace API token. Used to call the Inference API for LLM responses.
|
| 65 |
+
# Get yours: https://huggingface.co/settings/tokens (free tier available)
|
| 66 |
+
# Required (app won't generate answers without it)
|
| 67 |
HF_TOKEN=your_huggingface_token_here
|
| 68 |
|
| 69 |
+
# ββ LLM Configuration βββββββββββββββββββββββββββββββββββββββ
|
| 70 |
+
|
| 71 |
+
# HuggingFace model ID used for answer generation.
|
| 72 |
+
# Check available models: https://huggingface.co/models?inference=warm&sort=trending
|
| 73 |
+
# Optional β defaults to "mistralai/Mistral-7B-Instruct-v0.3"
|
| 74 |
# LLM_MODEL=mistralai/Mistral-7B-Instruct-v0.3
|
| 75 |
+
|
| 76 |
+
# Sampling temperature (0.0 = deterministic, 1.0 = very creative).
|
| 77 |
+
# Optional β defaults to 0.3
|
| 78 |
# LLM_TEMPERATURE=0.3
|
| 79 |
+
|
| 80 |
+
# Maximum number of tokens the LLM can generate per response.
|
| 81 |
+
# Optional β defaults to 1024
|
| 82 |
# LLM_MAX_NEW_TOKENS=1024
|
| 83 |
|
| 84 |
+
# ββ Embeddings (Optional β defaults shown)ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 85 |
+
|
| 86 |
+
# SentenceTransformer model ID for generating document embeddings.
|
| 87 |
+
# Model is downloaded once and cached locally. No external API call.
|
| 88 |
+
# Optional β defaults to "sentence-transformers/all-MiniLM-L6-v2"
|
| 89 |
# EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
|
| 90 |
|
| 91 |
+
# Dimension of the embedding vectors (must match the model output).
|
| 92 |
+
# Optional β defaults to 384
|
| 93 |
+
# EMBEDDING_DIMENSION=384
|
| 94 |
+
|
| 95 |
# ββ RAG Config (Optional β defaults shown) βββββββββββ
|
| 96 |
+
|
| 97 |
+
# ββ ChromaDB (Vector Store) βββββββββββββββββββββββββββββββββ
|
| 98 |
+
|
| 99 |
+
# Directory where ChromaDB persists its vector index to disk.
|
| 100 |
+
# Optional β defaults to "./data/chroma_db"
|
| 101 |
+
# CHROMA_PERSIST_DIR=./data/chroma_db
|
| 102 |
+
|
| 103 |
+
# ββ Document Chunking βββββββββββββββββββββββββββββββββββββββ
|
| 104 |
+
|
| 105 |
+
# Number of characters per document chunk.
|
| 106 |
+
# Larger chunks give more context; smaller chunks improve retrieval precision.
|
| 107 |
+
# Optional β defaults to 1000
|
| 108 |
# CHUNK_SIZE=1000
|
| 109 |
+
|
| 110 |
+
# Character overlap between consecutive chunks. Helps maintain context at boundaries.
|
| 111 |
+
# Optional β defaults to 200
|
| 112 |
# CHUNK_OVERLAP=200
|
| 113 |
+
|
| 114 |
+
# ββ Retrieval βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 115 |
+
|
| 116 |
+
# Number of candidate chunks retrieved from the vector store during semantic search.
|
| 117 |
+
# Optional β defaults to 10
|
| 118 |
# TOP_K_RETRIEVAL=10
|
| 119 |
+
|
| 120 |
+
# Number of top chunks passed to the LLM after cross-encoder reranking.
|
| 121 |
+
# Must be β€ TOP_K_RETRIEVAL.
|
| 122 |
+
# Optional β defaults to 5
|
| 123 |
# TOP_K_RERANK=5
|
| 124 |
|
| 125 |
+
# Cross-encoder model used for reranking retrieved chunks by relevance.
|
| 126 |
+
# Optional β defaults to "cross-encoder/ms-marco-MiniLM-L-6-v2"
|
| 127 |
+
# RERANKER_MODEL=cross-encoder/ms-marco-MiniLM-L-6-v2
|
| 128 |
+
|
| 129 |
+
# ββ (Legacy) Flask-Only Variables βββββββββββββββββββββββββββ
|
| 130 |
+
# These are only used if you run the old Flask app (app.py) instead of FastAPI.
|
| 131 |
+
# They are ignored by the new FastAPI backend.
|
| 132 |
+
|
| 133 |
+
# MONGO_URI=mongodb://localhost:27017/pdf_assistant
|
| 134 |
+
# GOOGLE_CLIENT_ID=your_google_client_id
|
| 135 |
+
# GOOGLE_CLIENT_SECRET=your_google_client_secret
|
README.md
CHANGED
|
@@ -378,22 +378,30 @@ docker compose up --build
|
|
| 378 |
|
| 379 |
## π¦ Environment Variables
|
| 380 |
|
| 381 |
-
| Variable | Required | Default | Description |
|
| 382 |
-
|---|---|---|---|
|
| 383 |
-
| `
|
| 384 |
-
| `
|
| 385 |
-
| `
|
| 386 |
-
| `
|
| 387 |
-
| `
|
| 388 |
-
| `
|
| 389 |
-
| `
|
| 390 |
-
| `
|
| 391 |
-
| `
|
| 392 |
-
| `
|
| 393 |
-
| `
|
| 394 |
-
| `
|
| 395 |
-
| `
|
| 396 |
-
| `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
|
| 398 |
<br/>
|
| 399 |
|
|
|
|
| 378 |
|
| 379 |
## π¦ Environment Variables
|
| 380 |
|
| 381 |
+
| Variable | Required | Default | Description | Where to Get It |
|
| 382 |
+
|---|---|---|---|---|
|
| 383 |
+
| `SECRET_KEY` | β
| β | JWT signing & session secret. Use a strong random string. | Generate: `python -c "import secrets; print(secrets.token_urlsafe(32))"` |
|
| 384 |
+
| `HF_TOKEN` | β
| β | HuggingFace API token for LLM inference via Inference API. | [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) (free) |
|
| 385 |
+
| `ENVIRONMENT` | β | `development` | Runtime mode. Set to `production` for deployment to lock CORS. | β |
|
| 386 |
+
| `DEBUG` | β | `False` | Enable debug mode with detailed error pages. Never enable in production. | β |
|
| 387 |
+
| `ALLOWED_ORIGINS` | β | `http://localhost:3000,http://localhost:7860` | Comma-separated CORS origins (only enforced in production). | Your deployed domain(s) |
|
| 388 |
+
| `DATABASE_URL` | β | `sqlite:///./data/app.db` | SQLAlchemy database connection string. | SQLite (default), or your Postgres/MySQL connection string |
|
| 389 |
+
| `JWT_ALGORITHM` | β | `HS256` | JWT signing algorithm. | β |
|
| 390 |
+
| `JWT_EXPIRY_HOURS` | β | `72` | JWT token lifetime in hours before re-login is required. | β |
|
| 391 |
+
| `UPLOAD_DIR` | β | `./data/uploads` | Local directory for storing uploaded documents. | β |
|
| 392 |
+
| `MAX_FILE_SIZE_MB` | β | `50` | Maximum allowed upload file size in MB. | β |
|
| 393 |
+
| `ALLOWED_EXTENSIONS` | β | `pdf,docx,txt,md` | Comma-separated list of permitted file extensions. | β |
|
| 394 |
+
| `CHROMA_PERSIST_DIR` | β | `./data/chroma_db` | Directory where ChromaDB persists its vector index. | β |
|
| 395 |
+
| `LLM_MODEL` | β | `Qwen/Qwen2.5-72B-Instruct` | HuggingFace model ID for answer generation. | [huggingface.co/models](https://huggingface.co/models?inference=warm&sort=trending) |
|
| 396 |
+
| `LLM_TEMPERATURE` | β | `0.3` | LLM sampling temperature (0 = deterministic, 1 = creative). | β |
|
| 397 |
+
| `LLM_MAX_NEW_TOKENS` | β | `1024` | Maximum tokens per LLM response. | β |
|
| 398 |
+
| `EMBEDDING_MODEL` | β | `sentence-transformers/all-MiniLM-L6-v2` | SentenceTransformer model for local embeddings (no external API). | [huggingface.co/sentence-transformers](https://huggingface.co/sentence-transformers) |
|
| 399 |
+
| `EMBEDDING_DIMENSION` | β | `384` | Embedding vector dimension (must match the model). | β |
|
| 400 |
+
| `RERANKER_MODEL` | β | `cross-encoder/ms-marco-MiniLM-L-6-v2` | Cross-encoder model for reranking retrieved chunks by relevance. | [huggingface.co/cross-encoder](https://huggingface.co/cross-encoder) |
|
| 401 |
+
| `CHUNK_SIZE` | β | `1000` | Characters per document chunk. Larger = more context, smaller = better precision. | β |
|
| 402 |
+
| `CHUNK_OVERLAP` | β | `200` | Overlap between consecutive chunks to maintain boundary context. | β |
|
| 403 |
+
| `TOP_K_RETRIEVAL` | β | `10` | Candidate chunks retrieved from vector store during semantic search. | β |
|
| 404 |
+
| `TOP_K_RERANK` | β | `5` | Final chunks passed to the LLM after reranking (must be β€ `TOP_K_RETRIEVAL`). | β |
|
| 405 |
|
| 406 |
<br/>
|
| 407 |
|