Fix: config parsing logic to use upstream model names for whitelist
This commit is contained in:
+41
-8
@@ -573,19 +573,52 @@ def active_monitor_loop():
|
|||||||
with open("config.yaml", "r", encoding="utf-8") as f:
|
with open("config.yaml", "r", encoding="utf-8") as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
lines = content.split("\n")
|
lines = content.split("\n")
|
||||||
current_model_name = None
|
|
||||||
print("Auto-discovering Volcengine models from config.yaml...")
|
print("Auto-discovering Volcengine models from config.yaml...")
|
||||||
|
|
||||||
|
# Robust Parsing Logic
|
||||||
|
current_entry = {"is_volc": False, "upstream_model": None}
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
sline = line.strip()
|
sline = line.strip()
|
||||||
|
|
||||||
|
# Start of a new model definition
|
||||||
if sline.startswith("- model_name:"):
|
if sline.startswith("- model_name:"):
|
||||||
current_model_name = sline.split(":", 1)[1].strip().strip("\"'")
|
# Commit previous entry if valid
|
||||||
if current_model_name:
|
if current_entry.get("is_volc") and current_entry.get(
|
||||||
# User requirement: Only models using HUOSHAN_BASE_URL are valid
|
"upstream_model"
|
||||||
if "api_base:" in sline and "HUOSHAN_BASE_URL" in sline:
|
):
|
||||||
INTERESTED_MODELS.add(current_model_name)
|
INTERESTED_MODELS.add(current_entry["upstream_model"])
|
||||||
# Deprecated: removed heuristics for "volc" or "volcengine/"
|
|
||||||
|
# Reset for new entry
|
||||||
|
current_entry = {"is_volc": False, "upstream_model": None}
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Check for Volcengine Base URL
|
||||||
|
if "api_base:" in sline and "HUOSHAN_BASE_URL" in sline:
|
||||||
|
current_entry["is_volc"] = True
|
||||||
|
|
||||||
|
# Capture Upstream Model Name
|
||||||
|
# Matches: "model: openai/deepseek..."
|
||||||
|
if sline.startswith("model:"):
|
||||||
|
try:
|
||||||
|
raw_val = sline.split(":", 1)[1].strip()
|
||||||
|
# Clean prefixes
|
||||||
|
clean = (
|
||||||
|
raw_val.replace("openai/", "")
|
||||||
|
.replace("azure/", "")
|
||||||
|
.replace("anthropic/", "")
|
||||||
|
)
|
||||||
|
current_entry["upstream_model"] = clean
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Commit the last entry
|
||||||
|
if current_entry.get("is_volc") and current_entry.get("upstream_model"):
|
||||||
|
INTERESTED_MODELS.add(current_entry["upstream_model"])
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f"Auto-discovered {len(INTERESTED_MODELS)} Active Volcengine models: {INTERESTED_MODELS}"
|
f"Auto-discovered {len(INTERESTED_MODELS)} Active Volcengine models (Upstream Names): {INTERESTED_MODELS}"
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Config Auto-discovery failed: {e}")
|
print(f"Config Auto-discovery failed: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user