mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-05 20:28:23 +00:00
Merge pull request #202 from Routstr/feature/configurable-model-exclusions
Feature/configurable model exclusions
This commit is contained in:
@@ -37,6 +37,7 @@ UPSTREAM_API_KEY=your-upstream-api-key
|
|||||||
# BASE_URL=https://openrouter.ai/api/v1
|
# BASE_URL=https://openrouter.ai/api/v1
|
||||||
# MODELS_PATH=models.json
|
# MODELS_PATH=models.json
|
||||||
# SOURCE=
|
# 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)
|
# UI Configuration (for Next.js frontend)
|
||||||
# These variables are prefixed with NEXT_PUBLIC_ to be accessible in the browser
|
# These variables are prefixed with NEXT_PUBLIC_ to be accessible in the browser
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Settings(BaseSettings):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_env_var(cls, field_name: str, raw_value: str) -> Any: # type: ignore[override]
|
def parse_env_var(cls, field_name: str, raw_value: str) -> Any: # type: ignore[override]
|
||||||
if field_name in {"cashu_mints", "cors_origins", "relays"}:
|
if field_name in {"cashu_mints", "cors_origins", "relays", "excluded_model_ids"}:
|
||||||
v = str(raw_value).strip()
|
v = str(raw_value).strip()
|
||||||
if v == "":
|
if v == "":
|
||||||
return []
|
return []
|
||||||
@@ -55,6 +55,18 @@ class Settings(BaseSettings):
|
|||||||
# Minimum per-request charge in millisatoshis when model pricing is free/zero
|
# Minimum per-request charge in millisatoshis when model pricing is free/zero
|
||||||
min_request_msat: int = Field(default=1, env="MIN_REQUEST_MSAT")
|
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
|
# Network
|
||||||
cors_origins: list[str] = Field(default_factory=lambda: ["*"], env="CORS_ORIGINS")
|
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")
|
tor_proxy_url: str = Field(default="socks5://127.0.0.1:9050", env="TOR_PROXY_URL")
|
||||||
@@ -305,4 +317,4 @@ class SettingsService:
|
|||||||
for k, v in data.items():
|
for k, v in data.items():
|
||||||
setattr(settings, k, v)
|
setattr(settings, k, v)
|
||||||
cls._current = settings
|
cls._current = settings
|
||||||
return settings
|
return settings
|
||||||
+14
-10
@@ -87,13 +87,15 @@ def fetch_openrouter_models(source_filter: str | None = None) -> list[dict]:
|
|||||||
model["id"] = model_id[len(source_prefix) :]
|
model["id"] = model_id[len(source_prefix) :]
|
||||||
model_id = model["id"]
|
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 (
|
if (
|
||||||
"(free)" in model.get("name", "")
|
"(free)" in model.get("name", "")
|
||||||
or model_id == "openrouter/auto"
|
or model_id in excluded_ids
|
||||||
or model_id == "google/gemini-2.5-pro-exp-03-25"
|
|
||||||
or model_id == "opengvlab/internvl3-78b"
|
|
||||||
or model_id == "openrouter/sonoma-dusk-alpha"
|
|
||||||
or model_id == "openrouter/sonoma-sky-alpha"
|
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -128,13 +130,15 @@ async def async_fetch_openrouter_models(source_filter: str | None = None) -> lis
|
|||||||
model["id"] = model_id[len(source_prefix) :]
|
model["id"] = model_id[len(source_prefix) :]
|
||||||
model_id = model["id"]
|
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 (
|
if (
|
||||||
"(free)" in model.get("name", "")
|
"(free)" in model.get("name", "")
|
||||||
or model_id == "openrouter/auto"
|
or model_id in excluded_ids
|
||||||
or model_id == "google/gemini-2.5-pro-exp-03-25"
|
|
||||||
or model_id == "opengvlab/internvl3-78b"
|
|
||||||
or model_id == "openrouter/sonoma-dusk-alpha"
|
|
||||||
or model_id == "openrouter/sonoma-sky-alpha"
|
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user