Yuvraj Sarathe commited on
Commit
675aa29
Β·
1 Parent(s): fa8f11a

Readme and .env.example updated with proper comments

Browse files
Files changed (2) hide show
  1. .env.example +115 -10
  2. README.md +24 -16
.env.example CHANGED
@@ -1,30 +1,135 @@
1
- # ── App Config ───────────────────────────────────────
 
 
 
 
 
 
 
 
 
2
  SECRET_KEY=change-me-in-production
3
- DATABASE_URL=sqlite:///./data/app.db
4
 
5
  # ── Environment & CORS ──────────────────────────────
 
 
 
 
6
  ENVIRONMENT=development
7
- # In production, set ENVIRONMENT=production and list your allowed origins:
8
- # ALLOWED_ORIGINS=https://yourapp.com,https://www.yourapp.com
 
 
 
 
 
 
 
9
  ALLOWED_ORIGINS=http://localhost:3000,http://localhost:7860
10
 
11
- # ── HuggingFace (Required for LLM) ──────────────────
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  HF_TOKEN=your_huggingface_token_here
13
 
14
- # ── LLM Model (Optional β€” defaults shown) ───────────
 
 
 
 
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
- # ── Upload (Optional) ───────────────────────────────
29
- # UPLOAD_DIR=./data/uploads
30
- # MAX_FILE_SIZE_MB=50
 
 
 
 
 
 
 
 
 
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
- | `HF_TOKEN` | βœ… | β€” | HuggingFace API token for LLM inference |
384
- | `SECRET_KEY` | βœ… | β€” | JWT signing secret (use a strong random string) |
385
- | `DATABASE_URL` | ❌ | `sqlite:///./data/app.db` | SQLAlchemy database URL |
386
- | `UPLOAD_DIR` | ❌ | `./data/uploads` | Directory for uploaded files |
387
- | `CHROMA_PERSIST_DIR` | ❌ | `./data/chroma_db` | ChromaDB persistence path |
388
- | `LLM_MODEL` | ❌ | `Qwen/Qwen2.5-72B-Instruct` | HuggingFace model ID |
389
- | `LLM_TEMPERATURE` | ❌ | `0.3` | LLM sampling temperature |
390
- | `LLM_MAX_NEW_TOKENS` | ❌ | `1024` | Max tokens per response |
391
- | `EMBEDDING_MODEL` | ❌ | `all-MiniLM-L6-v2` | SentenceTransformer model |
392
- | `CHUNK_SIZE` | ❌ | `1000` | Document chunk size (characters) |
393
- | `CHUNK_OVERLAP` | ❌ | `200` | Overlap between chunks |
394
- | `TOP_K_RETRIEVAL` | ❌ | `10` | Candidates retrieved from vector store |
395
- | `TOP_K_RERANK` | ❌ | `5` | Final chunks passed to LLM after reranking |
396
- | `MAX_FILE_SIZE_MB` | ❌ | `50` | Maximum upload file size |
 
 
 
 
 
 
 
 
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