Spaces:
Sleeping
Sleeping
Delete config.py
Browse files
config.py
DELETED
|
@@ -1,78 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
from pydantic_settings import BaseSettings, SettingsConfigDict
|
| 3 |
-
from functools import lru_cache
|
| 4 |
-
|
| 5 |
-
class Settings(BaseSettings):
|
| 6 |
-
#openai llm service
|
| 7 |
-
openai_api_key: str
|
| 8 |
-
chat_model: str = "gpt-4o-mini"
|
| 9 |
-
llm_temperature: float = 0.1
|
| 10 |
-
llm_max_tokens: int = 1024
|
| 11 |
-
|
| 12 |
-
#bge embeddings
|
| 13 |
-
embedding_model: str = "BAAI/bge-large-en-v1.5"
|
| 14 |
-
embedding_dimensions: int = 1024
|
| 15 |
-
embedding_device: str = "cuda"
|
| 16 |
-
embedding_batch_size: int = 32
|
| 17 |
-
embedding_normalize: bool = True
|
| 18 |
-
|
| 19 |
-
#FAISS
|
| 20 |
-
faiss_index_path: str = "./faiss_indexes"
|
| 21 |
-
faiss_index_name: str = "prod_rag"
|
| 22 |
-
|
| 23 |
-
#Chunking
|
| 24 |
-
chunk_size: int = 800
|
| 25 |
-
chunk_overlap: int = 150
|
| 26 |
-
min_chunk_size: int = 100
|
| 27 |
-
|
| 28 |
-
#retrieval
|
| 29 |
-
top_k_retrieval: int = 20
|
| 30 |
-
top_k_rerank: int = 6
|
| 31 |
-
mmr_lambda: float = 0.6
|
| 32 |
-
bm25_weight: float = 0.4
|
| 33 |
-
vector_weight: float = 0.6
|
| 34 |
-
|
| 35 |
-
#memory
|
| 36 |
-
max_history_turns: int = 10
|
| 37 |
-
context_window_tokens: int = 8000
|
| 38 |
-
|
| 39 |
-
#cache
|
| 40 |
-
cache_enabled: bool = False
|
| 41 |
-
redis_url: str = "redis://localhost:6379"
|
| 42 |
-
cache_ttl_seconds: int = 3600
|
| 43 |
-
semantic_cache_threshold: float = 0.95
|
| 44 |
-
|
| 45 |
-
#api
|
| 46 |
-
api_title: str = "Production RAG API"
|
| 47 |
-
api_version: str = "1.0.0"
|
| 48 |
-
cors_origins: list[str] = ["*"]
|
| 49 |
-
rate_limit_per_minute: int = 60
|
| 50 |
-
|
| 51 |
-
#guardrails
|
| 52 |
-
guardrails_use_llama_guard: bool = True
|
| 53 |
-
guardrails_model_id: str = "meta-llama/Llama-Guard-3-1B"
|
| 54 |
-
guardrails_max_new_tokens: int = 32
|
| 55 |
-
guardrails_local_model_path: str | None = None
|
| 56 |
-
guardrails_local_files_only: bool = True
|
| 57 |
-
guardrails_download_if_missing: bool = True
|
| 58 |
-
guardrails_require_harm_intent_for_llama_unsafe: bool = True
|
| 59 |
-
guardrails_risk_block_threshold: float = 0.50
|
| 60 |
-
guardrails_unsafe_base_score: float = 0.20
|
| 61 |
-
hf_token: str | None = None
|
| 62 |
-
|
| 63 |
-
#evaluation
|
| 64 |
-
faithfullness_threshold: float = 0.7
|
| 65 |
-
answer_relevance_threshold: float = 0.7
|
| 66 |
-
|
| 67 |
-
model_config = SettingsConfigDict(
|
| 68 |
-
env_file=os.path.join(os.path.dirname(__file__), ".env"),
|
| 69 |
-
env_file_encoding="utf-8",
|
| 70 |
-
case_sensitive=False
|
| 71 |
-
)
|
| 72 |
-
|
| 73 |
-
@lru_cache(maxsize=1)
|
| 74 |
-
def get_settings() -> Settings:
|
| 75 |
-
return Settings()
|
| 76 |
-
|
| 77 |
-
settings = get_settings()
|
| 78 |
-
print(f"[Config] Loaded. Model: {settings.chat_model}, Embedding Model: {settings.embedding_model},EmbedDim: {settings.embedding_dimensions}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|