38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
import os
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class Settings:
|
|
port: int
|
|
api_key: str | None
|
|
base_url: str
|
|
model: str
|
|
default_system_prompt: str
|
|
data_dir: Path
|
|
max_tool_rounds: int = 5
|
|
max_tool_calls_per_turn: int = 10
|
|
tool_timeout_seconds: float = 5.0
|
|
|
|
@classmethod
|
|
def from_env(cls) -> "Settings":
|
|
load_dotenv(dotenv_path=Path.cwd() / ".env", override=False)
|
|
return cls(
|
|
port=int(os.getenv("SERVICE_PORT", "8000")),
|
|
api_key=os.getenv("DEEPSEEK_API_KEY"),
|
|
base_url=os.getenv("DEEPSEEK_BASE_URL", "https://api.deepseek.com"),
|
|
model=os.getenv("DEEPSEEK_MODEL", "deepseek-v4-flash"),
|
|
default_system_prompt=os.getenv(
|
|
"DEFAULT_SYSTEM_PROMPT", "You are a helpful assistant."
|
|
),
|
|
data_dir=Path(os.getenv("CHAT_DATA_DIR", "data")),
|
|
max_tool_rounds=int(os.getenv("MAX_TOOL_ROUNDS", "5")),
|
|
max_tool_calls_per_turn=int(
|
|
os.getenv("MAX_TOOL_CALLS_PER_TURN", "10")
|
|
),
|
|
tool_timeout_seconds=float(os.getenv("TOOL_TIMEOUT_SECONDS", "5")),
|
|
)
|