Data-Flow / config.py
transformer03's picture
added the toggle for fallback
5875a4c
Raw
History Blame Contribute Delete
2.82 kB
# config.py
import os
import sys
import logging
import warnings
# --- Suppress Noisy Warnings ---
warnings.filterwarnings("ignore", category=UserWarning, module="onnxruntime")
# --- Setup Logging ---
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
# --- Project Base Directory ---
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# --- Hugging Face Secrets / Environment Variables ---
# In Hugging Face Spaces, secrets are automatically injected as environment variables.
# We fetch them directly from os.getenv. No .env files or external SDKs needed.
try:
from dotenv import load_dotenv
# Prefer a .env located at the repo root (one level above this config file)
dotenv_path = os.path.join(BASE_DIR, "..", ".env")
if os.path.exists(dotenv_path):
load_dotenv(dotenv_path)
else:
# Default discovery (will load from current working directory if present)
load_dotenv()
except Exception:
# If dotenv isn't available or fails, continue — HF Spaces injects env vars.
pass
MISTRAL_API_KEY = os.getenv("MISTRAL_API_KEY")
SEARCH_API_KEY = os.getenv("SEARCH_API_KEY")
CSE_ID = os.getenv("CSE_ID")
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
# --- Application Authentication ---
APP_PASSWORD = os.getenv("APP_PASSWORD")
APP_VERSION = "v109.0-DualDB-Context"
# --- Primary Supabase Credentials (Storage & Run Outputs) ---
SUPABASE_URL = os.getenv("SUPABASE_URL")
SUPABASE_KEY = os.getenv("SUPABASE_KEY")
SUPABASE_SERVICE_ROLE_KEY = os.getenv("SUPABASE_SERVICE_ROLE_KEY")
SUPABASE_CONFIGURED = bool(SUPABASE_URL and SUPABASE_KEY)
# --- Secondary Supabase Credentials (Read-Only Metadata Context) ---
SUPABASE_URL_1 = os.getenv("SUPABASE_URL_1")
SUPABASE_KEY_1 = os.getenv("SUPABASE_KEY_1")
# --- Model Configuration ---
MISTRAL_MODEL = "mistral-large-latest"
QWEN_EMBEDDING_MODEL = "qwen/qwen3-embedding-8b"
PERPLEXITY_SONAR_MODEL = "perplexity/sonar"
LLAMA_VERIFIER_MODEL = "meta-llama/llama-3.3-70b-instruct"
CROSS_ENCODER_MODEL = 'cross-encoder/ms-marco-MiniLM-L-6-v2'
SPACY_MODEL = 'en_core_web_sm'
# --- File & Execution Configuration ---
OUTPUT_DIR = os.path.join(BASE_DIR, "outputs")
CRAWL_CACHE_DIR = os.path.join(BASE_DIR, "crawl_cache")
KNOWLEDGE_CACHE_DIR = os.path.join(BASE_DIR, "knowledge_cache")
VECTOR_DB_PATH = os.path.join(BASE_DIR, "vector_db")
# Analytics Directories
GEMINI_ANALYTICS_DIR = os.path.join(OUTPUT_DIR, "gemini_analytics")
SONAR_ANALYTICS_DIR = os.path.join(OUTPUT_DIR, "sonar_analytics")
# --- Performance & Tuning Configuration ---
TOP_N_URLS_TO_PROCESS = 3
MAX_SEARCH_RESULTS = 10
MAX_RETRIES = 3
DEBUG = True
MAX_CONCURRENT_CRAWLERS = 2
MIN_CONFIDENCE_THRESHOLD = 0.65
RAG_CANDIDATE_POOL_SIZE = 50
RAG_FINAL_EVIDENCE_COUNT = 5