Spaces:
Running
Running
sync: 171 file da Baida98/AI@4df3de8e (2026-08-23 17:33 UTC)
Browse files- models/ai_client.py +17 -2
models/ai_client.py
CHANGED
|
@@ -113,11 +113,26 @@ class AIClient:
|
|
| 113 |
model-selection variables deliberately win so emergency model migrations
|
| 114 |
do not require reading or mutating provider secrets in the database.
|
| 115 |
"""
|
| 116 |
-
database_model = str(row.get("default_model", ""))
|
| 117 |
row_base_url = str(row.get("base_url", "")).rstrip("/")
|
| 118 |
for definition in _PROVIDER_DEFS:
|
| 119 |
if row_base_url == definition["base_url"].rstrip("/"):
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
return database_model
|
| 122 |
|
| 123 |
@staticmethod
|
|
|
|
| 113 |
model-selection variables deliberately win so emergency model migrations
|
| 114 |
do not require reading or mutating provider secrets in the database.
|
| 115 |
"""
|
| 116 |
+
database_model = str(row.get("default_model", "")).strip()
|
| 117 |
row_base_url = str(row.get("base_url", "")).rstrip("/")
|
| 118 |
for definition in _PROVIDER_DEFS:
|
| 119 |
if row_base_url == definition["base_url"].rstrip("/"):
|
| 120 |
+
# Explicit runtime configuration always wins over persisted DB values.
|
| 121 |
+
configured_model = os.getenv(definition["model_env"], "").strip()
|
| 122 |
+
if configured_model:
|
| 123 |
+
return configured_model
|
| 124 |
+
# Supabase may retain a model retired by the provider. Do not let a
|
| 125 |
+
# stale row override the tested repository default after deployment.
|
| 126 |
+
if (
|
| 127 |
+
definition["name"] == "groq"
|
| 128 |
+
and database_model in {
|
| 129 |
+
"llama-3.3-70b-versatile",
|
| 130 |
+
"llama-3.1-70b-versatile",
|
| 131 |
+
"llama-3.1-8b-instant",
|
| 132 |
+
}
|
| 133 |
+
):
|
| 134 |
+
return definition["default_model"]
|
| 135 |
+
return database_model or definition["default_model"]
|
| 136 |
return database_model
|
| 137 |
|
| 138 |
@staticmethod
|