mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-16 23:01:06 +02:00
chore: ran linting
This commit is contained in:
parent
b9b4d0b377
commit
cd25175b84
14 changed files with 78 additions and 82 deletions
|
|
@ -277,9 +277,7 @@ async def resolve_or_get_pinned_llm_config_id(
|
|||
c for c in _global_candidates() if int(c.get("id", 0)) not in excluded_ids
|
||||
]
|
||||
if not candidates:
|
||||
raise ValueError(
|
||||
"No usable global LLM configs are available for Auto mode"
|
||||
)
|
||||
raise ValueError("No usable global LLM configs are available for Auto mode")
|
||||
candidate_by_id = {int(c["id"]): c for c in candidates}
|
||||
|
||||
# Reuse an existing valid pin without re-checking current quota (no silent
|
||||
|
|
|
|||
|
|
@ -405,9 +405,7 @@ class OpenRouterIntegrationService:
|
|||
# Re-blend health scores against the freshly fetched catalogue. Also
|
||||
# re-stamps health for any YAML-curated cfg with provider==OPENROUTER
|
||||
# so a hand-picked dead OR model is gated like a dynamic one.
|
||||
await self._enrich_health_safely(
|
||||
static_configs + new_configs, log_summary=True
|
||||
)
|
||||
await self._enrich_health_safely(static_configs + new_configs, log_summary=True)
|
||||
|
||||
# Rebuild the LiteLLM router so freshly fetched configs flow through
|
||||
# (dynamic OR premium entries now opt into the pool, free ones stay
|
||||
|
|
@ -415,8 +413,8 @@ class OpenRouterIntegrationService:
|
|||
# reset cached context-window profiles).
|
||||
try:
|
||||
from app.config import config as _app_config
|
||||
from app.services.llm_router_service import LLMRouterService
|
||||
from app.services.llm_router_service import (
|
||||
LLMRouterService,
|
||||
_router_instance_cache as _chat_router_cache,
|
||||
)
|
||||
|
||||
|
|
@ -426,9 +424,7 @@ class OpenRouterIntegrationService:
|
|||
)
|
||||
_chat_router_cache.clear()
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"OpenRouter refresh: router rebuild skipped (%s)", exc
|
||||
)
|
||||
logger.warning("OpenRouter refresh: router rebuild skipped (%s)", exc)
|
||||
|
||||
@staticmethod
|
||||
def _tier_counts(configs: list[dict]) -> dict[str, int]:
|
||||
|
|
@ -475,19 +471,11 @@ class OpenRouterIntegrationService:
|
|||
return
|
||||
|
||||
premium_pool = sorted(
|
||||
[
|
||||
c
|
||||
for c in or_cfgs
|
||||
if str(c.get("billing_tier", "")).lower() == "premium"
|
||||
],
|
||||
[c for c in or_cfgs if str(c.get("billing_tier", "")).lower() == "premium"],
|
||||
key=lambda c: -int(c.get("quality_score_static") or 0),
|
||||
)[:_HEALTH_ENRICH_TOP_N_PREMIUM]
|
||||
free_pool = sorted(
|
||||
[
|
||||
c
|
||||
for c in or_cfgs
|
||||
if str(c.get("billing_tier", "")).lower() == "free"
|
||||
],
|
||||
[c for c in or_cfgs if str(c.get("billing_tier", "")).lower() == "free"],
|
||||
key=lambda c: -int(c.get("quality_score_static") or 0),
|
||||
)[:_HEALTH_ENRICH_TOP_N_FREE]
|
||||
# De-duplicate while preserving order: a cfg shouldn't fall in both
|
||||
|
|
@ -507,9 +495,7 @@ class OpenRouterIntegrationService:
|
|||
api_key = str(self._settings.get("api_key") or "")
|
||||
semaphore = asyncio.Semaphore(_HEALTH_ENRICH_CONCURRENCY)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
timeout=_HEALTH_FETCH_TIMEOUT_SEC
|
||||
) as client:
|
||||
async with httpx.AsyncClient(timeout=_HEALTH_FETCH_TIMEOUT_SEC) as client:
|
||||
results = await asyncio.gather(
|
||||
*(
|
||||
self._fetch_endpoints(client, semaphore, api_key, cfg)
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ sort and a SHA256 pick.
|
|||
|
||||
Score components (0-100 scale, higher is better):
|
||||
|
||||
* ``static_score_or`` – derived from the bulk ``/api/v1/models`` payload
|
||||
* ``static_score_or`` - derived from the bulk ``/api/v1/models`` payload
|
||||
(provider prestige + ``created`` recency + pricing band + context window
|
||||
+ capabilities + narrow tiny/legacy slug penalty).
|
||||
* ``static_score_yaml`` – same shape for hand-curated YAML configs, plus
|
||||
* ``static_score_yaml`` - same shape for hand-curated YAML configs, plus
|
||||
an operator-trust bonus (the operator deliberately picked this model).
|
||||
* ``aggregate_health`` – run on per-model ``/api/v1/models/{id}/endpoints``
|
||||
* ``aggregate_health`` - run on per-model ``/api/v1/models/{id}/endpoints``
|
||||
responses; returns ``(gated, score_or_none)``.
|
||||
|
||||
The blended ``quality_score`` (0.5 * static + 0.5 * health) is computed in
|
||||
|
|
@ -281,9 +281,7 @@ def static_score_yaml(cfg: dict) -> int:
|
|||
model_name = cfg.get("model_name") or ""
|
||||
litellm_params = cfg.get("litellm_params") or {}
|
||||
lookup_name = (
|
||||
litellm_params.get("base_model")
|
||||
or litellm_params.get("model")
|
||||
or model_name
|
||||
litellm_params.get("base_model") or litellm_params.get("model") or model_name
|
||||
)
|
||||
|
||||
ctx = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue