File size: 1,514 Bytes
5dccc28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90b7bb0
 
 
d197c9d
 
 
 
5dccc28
90b7bb0
5dccc28
9006e65
5dccc28
 
 
 
 
 
 
 
 
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
from functools import lru_cache
from pathlib import Path

from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")

    app_name: str = "DocsQA Assignment"
    secret_key: str = "change-me"
    algorithm: str = "HS256"
    access_token_expire_minutes: int = 720
    database_url: str = "postgresql+psycopg://postgres:postgres@localhost:5432/postgres"
    upload_directory: str = "./uploads"
    storage_backend: str = "local"
    supabase_url: str | None = None
    supabase_service_role_key: str | None = None
    supabase_storage_bucket: str = "documents"
    supabase_storage_prefix: str = "docsqa"
    model_name: str = "llama-3.1-8b-instant"
    embedding_model: str = "mixedbread-ai/mxbai-embed-large-v1"
    embedding_dimensions: int = 1024
    jina_api_key: str | None = None
    jina_api_base: str = "https://api.jina.ai/v1/embeddings"
    jina_embedding_model: str = "jina-embeddings-v3"
    jina_reranker_api_base: str = "https://api.jina.ai/v1/rerank"
    jina_reranker_model: str = "jina-reranker-v3"
    retrieval_k: int = 4
    rerank_candidate_k: int = 12
    groq_api_key: str | None = None
    web_search_provider: str = "tavily"
    tavily_api_key: str | None = None
    cookie_secure: bool = False

    @property
    def upload_path(self) -> Path:
        return Path(self.upload_directory)


@lru_cache
def get_settings() -> Settings:
    return Settings()