From ec60dbe56833f36a343497ab64417b043ca54283 Mon Sep 17 00:00:00 2001 From: Shroominic Date: Sun, 23 Nov 2025 12:29:00 -0800 Subject: [PATCH] half undo 83a49a3 to not introduce extra db-settings --- .env.example | 1 - routstr/core/settings.py | 16 ++-------------- routstr/payment/models.py | 25 +++++++++++-------------- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/.env.example b/.env.example index 2e797d51..d093e006 100644 --- a/.env.example +++ b/.env.example @@ -37,7 +37,6 @@ UPSTREAM_API_KEY=your-upstream-api-key # BASE_URL=https://openrouter.ai/api/v1 # MODELS_PATH=models.json # SOURCE= -# EXCLUDED_MODEL_IDS="openrouter/auto,google/gemini-2.5-pro-exp-03-25,opengvlab/internvl3-78b,openrouter/sonoma-dusk-alpha,openrouter/sonoma-sky-alpha" # UI Configuration (for Next.js frontend) # These variables are prefixed with NEXT_PUBLIC_ to be accessible in the browser diff --git a/routstr/core/settings.py b/routstr/core/settings.py index a13a3d2b..302df24d 100644 --- a/routstr/core/settings.py +++ b/routstr/core/settings.py @@ -16,7 +16,7 @@ class Settings(BaseSettings): @classmethod def parse_env_var(cls, field_name: str, raw_value: str) -> Any: # type: ignore[override] - if field_name in {"cashu_mints", "cors_origins", "relays", "excluded_model_ids"}: + if field_name in {"cashu_mints", "cors_origins", "relays"}: v = str(raw_value).strip() if v == "": return [] @@ -55,18 +55,6 @@ class Settings(BaseSettings): # Minimum per-request charge in millisatoshis when model pricing is free/zero min_request_msat: int = Field(default=1, env="MIN_REQUEST_MSAT") - # Model filtering - excluded_model_ids: list[str] = Field( - default_factory=lambda: [ - "openrouter/auto", - "google/gemini-2.5-pro-exp-03-25", - "opengvlab/internvl3-78b", - "openrouter/sonoma-dusk-alpha", - "openrouter/sonoma-sky-alpha" - ], - env="EXCLUDED_MODEL_IDS" - ) - # Network cors_origins: list[str] = Field(default_factory=lambda: ["*"], env="CORS_ORIGINS") tor_proxy_url: str = Field(default="socks5://127.0.0.1:9050", env="TOR_PROXY_URL") @@ -317,4 +305,4 @@ class SettingsService: for k, v in data.items(): setattr(settings, k, v) cls._current = settings - return settings \ No newline at end of file + return settings diff --git a/routstr/payment/models.py b/routstr/payment/models.py index 61225b31..2e3fbd9c 100644 --- a/routstr/payment/models.py +++ b/routstr/payment/models.py @@ -2,6 +2,7 @@ import asyncio import json import random from pathlib import Path +from typing import Final from urllib.request import urlopen import httpx @@ -19,6 +20,14 @@ logger = get_logger(__name__) models_router = APIRouter() +DEFAULT_EXCLUDED_MODEL_IDS: Final[set[str]] = { + "openrouter/auto", + "google/gemini-2.5-pro-exp-03-25", + "opengvlab/internvl3-78b", + "openrouter/sonoma-dusk-alpha", + "openrouter/sonoma-sky-alpha", +} + class Architecture(BaseModel): modality: str @@ -87,15 +96,9 @@ def fetch_openrouter_models(source_filter: str | None = None) -> list[dict]: model["id"] = model_id[len(source_prefix) :] model_id = model["id"] - # Check if model should be excluded based on configuration - try: - excluded_ids = getattr(settings, "excluded_model_ids", []) - except Exception: - excluded_ids = [] - if ( "(free)" in model.get("name", "") - or model_id in excluded_ids + or model_id in DEFAULT_EXCLUDED_MODEL_IDS ): continue @@ -130,15 +133,9 @@ async def async_fetch_openrouter_models(source_filter: str | None = None) -> lis model["id"] = model_id[len(source_prefix) :] model_id = model["id"] - # Check if model should be excluded based on configuration - try: - excluded_ids = getattr(settings, "excluded_model_ids", []) - except Exception: - excluded_ids = [] - if ( "(free)" in model.get("name", "") - or model_id in excluded_ids + or model_id in DEFAULT_EXCLUDED_MODEL_IDS ): continue