Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

4.1 KB
Raw Blame
"""
Server runtime environment settings.

These settings control server-level parameters that require a restart
to take effect. They are not editable via the UI.
"""

from ..env_settings import BooleanSetting, IntegerSetting

TRUSTED_PROXY_COUNT = IntegerSetting(
    key="server.trusted_proxy_count",
    description=(
        "Number of X-Forwarded-For entries your trusted reverse proxies "
        "append -- one per appending hop for an ordinary proxy, so CDN -> "
        "nginx is 2. Used by the rate limiter only while "
        "TRUST_PROXY_HEADERS is NOT set: it then reads the N-th entry from "
        "the right, provided the direct peer is private/loopback or, once "
        "a restricted LDR_SERVER_FORWARDED_ALLOW_IPS is set, listed there "
        "(otherwise it keys on the direct peer). N must be exact: too "
        "small keys every client on a proxy's address, too large reads an "
        "entry the client wrote itself (or, when the header is shorter "
        "than N, keys on the direct peer). Zero (default) disables hop "
        "counting and keeps the single-proxy behaviour (the right-most "
        "entry). With TRUST_PROXY_HEADERS=true this value has no effect -- "
        "list every hop in LDR_SERVER_FORWARDED_ALLOW_IPS instead -- and "
        "setting it while that allow-list still trusts every peer (the "
        'default "*") makes LDR refuse to start. For N >= 2, every '
        "intermediate hop must be unreachable directly by clients, or a "
        "client connecting to an inner hop chooses the entry read. Does not "
        "affect X-Forwarded-Proto/scheme detection. See 'Proxy chains' in "
        "docs/deployment/reverse-proxy.md. Accepted values are ASCII "
        "decimal integers from 0 to 16 (surrounding whitespace is ignored "
        "and -0 reads as 0); an empty or whitespace-only value counts as "
        "unset, and any other invalid value prevents startup."
    ),
    min_value=0,
    # A real deployment has one or two hops in front of LDR; a CDN plus a
    # tunnel plus an ingress is three or four. 16 sits far above anything
    # operationally sensible while still turning a fat-fingered value (a
    # pasted port number, a year) into a startup failure that names the
    # variable -- instead of a hop count no X-Forwarded-For chain can
    # satisfy, which would silently collapse every client behind the proxy
    # into the direct peer's single rate-limit bucket.
    max_value=16,
    default=0,
    raise_on_validation_error=True,
    # Reject "1_0" (int() reads that as 10), "+3", and non-ASCII decimal
    # digits such as "٣": a trust-boundary count must mean what it
    # looks like.
    strict_digits=True,
)


SERVER_SETTINGS = [
    IntegerSetting(
        key="server.max_concurrent_research",
        description="Server-wide maximum concurrent research operations. Requires restart.",
        min_value=1,
        max_value=1000,
        default=10,
        deprecated_env_var="LDR_MAX_GLOBAL_CONCURRENT",
    ),
    IntegerSetting(
        key="web.threadpool_max_threads",
        description=(
            "Maximum AnyIO worker threads serving synchronous route "
            "handlers. Leave unset to use AnyIO's default of 40. Every "
            "plain `def` route occupies one worker for its whole duration, "
            "and the pool is shared with async dependency solving and "
            "response validation, so exhausting it slows async routes too. "
            "Raise it if concurrent requests queue behind each other under "
            "load; each extra thread costs context switching and contends "
            "for the same per-user database pool. Requires restart."
        ),
        min_value=1,
        max_value=1000,
        default=None,
    ),
    BooleanSetting(
        key="vite.dev_mode",
        description=(
            "When true, templates link to the Vite dev server at "
            "http://localhost:5173 for HMR instead of the built manifest "
            "under static/dist. Set to true when running `npm run dev` "
            "alongside the Python server."
        ),
        default=False,
    ),
    TRUSTED_PROXY_COUNT,
]