28 lines
818 B
Python
28 lines
818 B
Python
from __future__ import annotations
|
|
import json
|
|
from pathlib import Path
|
|
|
|
BASE = Path('/srv/prime-core')
|
|
ROUTER_CFG = BASE / 'config' / 'model-router.yaml'
|
|
STATE_DIR = BASE / 'state'
|
|
OAUTH_STATE = STATE_DIR / 'oauth'
|
|
TOKENS_FILE = STATE_DIR / 'tokens.enc'
|
|
|
|
|
|
def load_router_config() -> dict:
|
|
# minimal yaml-ish parser fallback to json if needed
|
|
text = ROUTER_CFG.read_text()
|
|
out = {}
|
|
current = None
|
|
for raw in text.splitlines():
|
|
line = raw.strip()
|
|
if not line or line.startswith('#'):
|
|
continue
|
|
if line.endswith(':') and not line.startswith('-'):
|
|
current = line[:-1]
|
|
out[current] = {}
|
|
elif ':' in line and current:
|
|
k, v = [x.strip() for x in line.split(':', 1)]
|
|
out[current][k] = v.strip('"')
|
|
return out
|