aivre / app /core /config.py
Vedang Barhate
chore: copied from assist repo
cfc8e23
raw
history blame
1.34 kB
import json
from dataclasses import asdict
from functools import lru_cache
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
"""Configuration for the retrieval and generation system"""
api_title: str = "NEXUS API"
api_version: str = "0.1.0"
chunk_size: int = 512
chunk_overlap: int = 256
embedding_model: str = "text-embedding-ada-002"
rerank_model: str = "cross-encoder/ms-marco-MiniLM-L-6-v2"
llm_model: str = "gpt-4o"
openai_api_key: str | None = None
use_colbert: bool = True
colbert_model: str = "answerdotai/answerai-colbert-small-v1"
colbert_top_k: int = 20
colbert_only: bool = False
bm25_top_k: int = 20
final_top_k: int = 5
bm25_weight: float = 0.50
colbert_weight: float = 0.50
use_reranking: bool = True
index_path: str = "./data/indexes/rag_index"
colbert_index_path: str = "./data/indexes/colbert_index"
markdown_directory: str = "./Markdown_files"
def save(self, path: str):
"""Save config to JSON"""
with open(path, "w") as f:
json.dump(asdict(self), f, indent=2)
@classmethod
def load(cls, path: str):
"""Load config from JSON"""
with open(path) as f:
return cls(**json.load(f))
@lru_cache
def get_settings():
return Settings()