File size: 2,807 Bytes
4db2d34
2eef9ea
 
 
 
 
 
 
4db2d34
2eef9ea
4db2d34
 
2eef9ea
4db2d34
2eef9ea
 
 
 
4db2d34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2eef9ea
4db2d34
 
 
 
 
 
 
 
 
 
 
 
 
 
2eef9ea
 
 
 
 
 
 
 
 
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
"""backend/core/config.py β€” All non-secret config lives here. Secrets come from .env."""
from functools import lru_cache
from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_file=".env", extra="ignore", case_sensitive=False)

    # ── Secrets (from .env) ───────────────────────────────────────────────────
    google_api_key: str = ""
    groq_api_key: str = ""
    serper_api_key: str = ""

    # ── App ───────────────────────────────────────────────────────────────────
    app_env: str = "development"
    app_host: str = "0.0.0.0"
    app_port: int = 8000
    log_level: str = "INFO"
    frontend_url: str = "http://localhost:5500"

    # ── Database ──────────────────────────────────────────────────────────────
    database_url: str = "sqlite+aiosqlite:///./agent_system.db"

    # ── Redis ─────────────────────────────────────────────────────────────────
    redis_host: str = "localhost"
    redis_port: int = 6379
    redis_db: int = 0
    redis_url: str = "redis://localhost:6379"
    redis_ttl: int = 86400

    # ── LLM provider: "gemini" or "groq" ─────────────────────────────────────
    llm_provider: str = "groq"

    # Gemini models
    planner_model: str = "gemini-2.5-flash"
    executor_model: str = "gemini-2.5-flash"
    critic_model: str = "gemini-2.5-flash"
    memory_model: str = "gemini-2.5-flash"

    # Groq models
    groq_planner_model: str = "llama-3.3-70b-versatile"
    groq_executor_model: str = "llama-3.3-70b-versatile"
    groq_critic_model: str = "llama-3.1-8b-instant"
    groq_memory_model: str = "llama-3.1-8b-instant"

    # ── Agent behaviour ───────────────────────────────────────────────────────
    max_iterations: int = 3
    max_retries: int = 1
    step_timeout: int = 60
    enable_reflection: bool = True
    enable_memory: bool = True
    max_plan_steps: int = 4
    max_output_tokens: int = 512

    @property
    def is_dev(self) -> bool:
        return self.app_env == "development"


@lru_cache(maxsize=1)
def get_settings() -> Settings:
    return Settings()