settings.py
Ricky/RAG_project/config/settings.py
"""
Static project configuration loaded from environment variables and .env.
Paths are anchored to the project root (the directory containing this package)
so the app works regardless of the current working directory.
"""
import os
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# Project root: two levels up from this file (config/settings.py → project root)
_PROJECT_ROOT = Path(__file__).resolve().parent.parent
def _path(relative: str) -> str:
"""Return an absolute path anchored to the project root."""
return str(_PROJECT_ROOT / relative)
# ---------------------------------------------------------------------------
# OpenRouter
# ---------------------------------------------------------------------------
OPENROUTER_API_KEY: str = os.getenv("OPENROUTER_API_KEY", "")
OPENROUTER_BASE_URL: str = os.getenv("OPENROUTER_BASE_URL", "https://openrouter.ai/api/v1").rstrip("/")
OPENROUTER_MODEL: str = os.getenv("OPENROUTER_MODEL", "openai/gpt-4o-mini")
# ---------------------------------------------------------------------------
# Ollama (embeddings — always local; LLM — fallback)
# ---------------------------------------------------------------------------
OLLAMA_BASE_URL: str = os.getenv("OLLAMA_BASE_URL", "http://127.0.0.1:11434").rstrip("/")
OLLAMA_LLM_MODEL: str = os.getenv("OLLAMA_LLM_MODEL", "llama3")
EMBEDDING_MODEL: str = os.getenv("OLLAMA_EMBEDDING_MODEL", "nomic-embed-text")
# ---------------------------------------------------------------------------
# ChromaDB
# ---------------------------------------------------------------------------
CHROMA_DB_PATH: str = _path("data/processed/chroma_db")
# ---------------------------------------------------------------------------
# Raw document directories
# ---------------------------------------------------------------------------
RAW_PDF_PATH: str = _path("data/raw/pdfs")
RAW_EXCEL_PATH: str = _path("data/raw/excel")
RAW_TEXT_PATH: str = _path("data/raw/text")
RAW_IMAGE_PATH: str = _path("data/raw/images")
# ---------------------------------------------------------------------------
# OCR
# ---------------------------------------------------------------------------
OCR_LANGUAGE: str = os.getenv("OCR_LANGUAGE", "eng")
TESSERACT_CMD: str = os.getenv("TESSERACT_CMD", "")
PDF_OCR_ENABLED: bool = os.getenv("PDF_OCR_ENABLED", "1") == "1"
PDF_OCR_MIN_CHARS: int = int(os.getenv("PDF_OCR_MIN_CHARS", "80"))
# ---------------------------------------------------------------------------
# Chunking
# ---------------------------------------------------------------------------
CHUNK_SIZE: int = 1000
CHUNK_OVERLAP: int = 200
関連記事
__init__.py
__init__.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/__init__.py).
記事を読む →auth.py
auth.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/admin/auth.py).
記事を読む →routes.py
routes.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/admin/routes.py).
記事を読む →config.py
config.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/config.py).
記事を読む →admin_ingest.py
admin_ingest.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/routes/admin_ingest.py).
記事を読む →admin_stats.py
admin_stats.py — python source code from the Ricky learning materials (Ricky/Cat Project Final/back_web-4/app/routes/admin_stats.py).
記事を読む →