Spaces:
Running
Running
File size: 8,220 Bytes
675aa29 26a0c00 c64b502 0cded53 675aa29 0cded53 675aa29 0cded53 675aa29 06966cb 3dfe460 675aa29 0326bb1 675aa29 26a0c00 c64b502 0326bb1 675aa29 26a0c00 675aa29 26a0c00 675aa29 26a0c00 c64b502 a1b3bc8 675aa29 26a0c00 675aa29 26a0c00 675aa29 c752a7a 675aa29 26a0c00 675aa29 26a0c00 675aa29 26a0c00 675aa29 26a0c00 675aa29 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | # Document AI Analyst β Environment Configuration
# Copy this file to backend/.env and fill in your values:
# cp .env.example backend/.env
# ββ Application Config ββββββββββββββββββββββββββββββββββββββββββββββ
# Secret key for signing JWT tokens and Flask sessions.
# Generate one: python -c "import secrets; print(secrets.token_urlsafe(32))"
# Required
SECRET_KEY=change-me-in-production
# ββ Environment & CORS ββββββββββββββββββββββββββββββ
# Runtime environment. Set to "production" in production.
# In production, ALLOWED_ORIGINS must be set explicitly (CORS will reject all others).
# Optional β defaults to "development"
ENVIRONMENT=development
# Debug mode. Enables detailed error pages and auto-reload.
# Do NOT enable in production.
# Optional β defaults to False
# DEBUG=False
# Comma-separated list of allowed CORS origins.
# Only used when ENVIRONMENT=production. When empty or during development, all origins are allowed.
# Optional β defaults to "http://localhost:3000,http://localhost:7860"
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:7860
# ββ Database βββββββββββββββββββββββββββββββββββββββββββββββββ
# SQLAlchemy database connection string.
# Default: SQLite stored at ./data/app.db
# For Postgres: postgresql+asyncpg://user:pass@host:5432/dbname
# Optional β defaults to sqlite:///./data/app.db
# DATABASE_URL=sqlite:///./data/app.db
# ββ Authentication ββββββββββββββββββββββββββββββββββββββββββ
# JWT signing algorithm. Leave as default unless you know what you're doing.
# Optional β defaults to "HS256"
# JWT_ALGORITHM=HS256
# JWT token expiry in hours. After this period, users must re-login.
# Optional β defaults to 72
# JWT_EXPIRY_HOURS=72
# Google OAuth client ID for backend ID-token verification.
# Use the same OAuth web client ID as NEXT_PUBLIC_GOOGLE_CLIENT_ID.
# Optional β required only for Google sign-in.
# GOOGLE_CLIENT_ID=your_google_oauth_client_id.apps.googleusercontent.com
# Google OAuth client ID exposed to the Next.js frontend for Google Identity Services.
# Add the frontend origin to your OAuth web client's authorized JavaScript origins.
# Optional β required only for Google sign-in.
# NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_google_oauth_client_id.apps.googleusercontent.com
# ββ Celery / Redis Background Processing βββββββββββββββββββ
# Redis URL used by FastAPI to enqueue PDF processing jobs.
# Optional β defaults to redis://localhost:6379/0
# CELERY_BROKER_URL=redis://localhost:6379/0
# Redis URL used by Celery to store task results/status.
# Optional β defaults to redis://localhost:6379/1
# CELERY_RESULT_BACKEND=redis://localhost:6379/1
# ββ File Upload βββββββββββββββββββββββββββββββββββββββββββββ
# Directory where uploaded documents (PDFs, DOCXs, etc.) are stored.
# Optional β defaults to "./data/uploads"
# UPLOAD_DIR=./data/uploads
# Maximum upload file size in megabytes.
# Optional β defaults to 50
# MAX_FILE_SIZE_MB=50
# Comma-separated list of allowed file extensions for upload.
# Optional β defaults to "pdf,docx,txt,md"
# ALLOWED_EXTENSIONS=pdf,docx,txt,md
# ββ HuggingFace (Required for LLM inference and OAuth) βββββββ
# HuggingFace API token. Used to call the Inference API for LLM responses.
# Get yours: https://huggingface.co/settings/tokens (free tier available)
# Required (app won't generate answers without it)
HF_TOKEN=your_huggingface_token_here
# HuggingFace OAuth variables for native login support
# Optional β required only for Hugging Face sign-in
HF_CLIENT_ID=your_hf_oauth_client_id
HF_CLIENT_SECRET=your_hf_oauth_client_secret
HF_REDIRECT_URI=http://localhost:8000/api/v1/auth/callback/huggingface
FRONTEND_URL=http://localhost:3000
# ββ LLM Configuration βββββββββββββββββββββββββββββββββββββββ
# HuggingFace model ID used for answer generation.
# Check available models: https://huggingface.co/models?inference=warm&sort=trending
# Optional β defaults to "mistralai/Mistral-7B-Instruct-v0.3"
# LLM_MODEL=mistralai/Mistral-7B-Instruct-v0.3
# Sampling temperature (0.0 = deterministic, 1.0 = very creative).
# Optional β defaults to 0.3
# LLM_TEMPERATURE=0.3
# Maximum number of tokens the LLM can generate per response.
# Optional β defaults to 1024
# LLM_MAX_NEW_TOKENS=1024
# ββ LangSmith Tracing (Optional) ββββββββββββββββββββββββ
# Enable LangSmith tracing for the backend RAG pipeline.
# Optional β defaults to False
# LANGSMITH_TRACING=False
# LangSmith API key.
# Optional β only needed when LANGSMITH_TRACING=True
# LANGSMITH_API_KEY=
# LangSmith API endpoint.
# Optional β defaults to "https://api.smith.langchain.com"
# LANGSMITH_ENDPOINT=https://api.smith.langchain.com
# LangSmith project name used for traced runs.
# Optional β defaults to "pdf-assistant-rag"
# LANGSMITH_PROJECT=pdf-assistant-rag
# ββ Embeddings (Optional β defaults shown)ββββββββββββββββββββββββββββββββββββββββββββββ
# SentenceTransformer model ID for generating document embeddings.
# Model is downloaded once and cached locally. No external API call.
# Optional β defaults to "sentence-transformers/all-MiniLM-L6-v2"
# EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
# Dimension of the embedding vectors (must match the model output).
# Optional β defaults to 384
# EMBEDDING_DIMENSION=384
# ββ RAG Config (Optional β defaults shown) βββββββββββ
# ββ Knowledge Graph / GraphRAG (Optional β defaults shown) βββββββββββββββββ
# Directory where GraphRAG stores per-document knowledge graphs.
# Optional β defaults to "./data/graphs"
# GRAPH_PERSIST_DIR=./data/graphs
# Maximum number of graph relationships appended to the RAG prompt.
# Optional β defaults to 12
# GRAPH_MAX_RELATIONSHIPS=12
# ββ ChromaDB (Vector Store) βββββββββββββββββββββββββββββββββ
# Directory where ChromaDB persists its vector index to disk.
# Optional β defaults to "./data/chroma_db"
# CHROMA_PERSIST_DIR=./data/chroma_db
# ββ Document Chunking βββββββββββββββββββββββββββββββββββββββ
# Number of characters per document chunk.
# Larger chunks give more context; smaller chunks improve retrieval precision.
# Optional β defaults to 1000
# CHUNK_SIZE=1000
# Character overlap between consecutive chunks. Helps maintain context at boundaries.
# Optional β defaults to 200
# CHUNK_OVERLAP=200
# ββ Retrieval βββββββββββββββββββββββββββββββββββββββββββββββ
# Number of candidate chunks retrieved from the vector store during semantic search.
# Optional β defaults to 10
# TOP_K_RETRIEVAL=10
# Number of top chunks passed to the LLM after cross-encoder reranking.
# Must be β€ TOP_K_RETRIEVAL.
# Optional β defaults to 5
# TOP_K_RERANK=5
# Cross-encoder model used for reranking retrieved chunks by relevance.
# Optional β defaults to "cross-encoder/ms-marco-MiniLM-L-6-v2"
# RERANKER_MODEL=cross-encoder/ms-marco-MiniLM-L-6-v2
# ββ (Legacy) Flask-Only Variables βββββββββββββββββββββββββββ
# These are only used if you run the old Flask app (app.py) instead of FastAPI.
# They are ignored by the new FastAPI backend.
# MONGO_URI=mongodb://localhost:27017/pdf_assistant
# GOOGLE_CLIENT_SECRET=your_google_client_secret
|