Spaces:
Sleeping
Sleeping
File size: 1,800 Bytes
26c651c 18600eb 48d70f7 f3be862 3681d0c 18600eb 9c56ca2 18600eb |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# config/config.py
from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, Any, Optional
class GenerationStrategy(str, Enum):
DEFAULT = "default"
MAJORITY_VOTING = "majority_voting"
BEST_OF_N = "best_of_n"
BEAM_SEARCH = "beam_search"
DVTS = "dvts"
COT = "chain_of_thought"
REACT = "react"
@dataclass
class ModelConfig:
model_kwargs: Dict[str, Any] = field(default_factory=dict)
tokenizer_kwargs: Dict[str, Any] = field(default_factory=dict)
quantization_kwargs: Dict[str, Any] = field(default_factory=dict)
@dataclass
class GenerationConfig:
num_samples: int = 5
depth: int = 3
breadth: int = 2
max_history_turns: int = 1
max_new_tokens: int = 50
temperature: float = 0.7
top_p: float = 0.9
top_k: int = 50
repetition_penalty: float = 1.1
length_penalty: float = 1.0
do_sample: bool = True
strategy: GenerationStrategy = GenerationStrategy.DEFAULT
#####
from pydantic_settings import BaseSettings
from pathlib import Path
import torch
class Settings(BaseSettings):
secret_key: str
api_key: str
MODEL_NAME: str = "meta-llama/Llama-3.2-3B-Instruct"
EMBEDDER_MODEL: str = "distiluse-base-multilingual-cased"
CHUNK_SIZE: int = 1000
CHUNK_OVERLAP: int = 100
CSV_URL: str = 'https://www.bofrost.de/datafeed/DE/products.csv'
PDF_FOLDER: Path = Path("./pdfs")
DEVICE: str = "cuda" if torch.cuda.is_available() else "cpu"
QUANTIZATION_BITS: int = 8
FAQ_ROOT_URL: str = "https://www.bofrost.de/faq/"
CACHE_DURATION: int = 3600
MAX_RETRIES: int = 3
TIMEOUT: int = 30
class Config:
extra = "allow" # This allows additional fields beyond those defined in the class
env_file = ".env"
settings = Settings()
|