feat: add detect_byok() public utility to cloud_session, bump v0.16.1
Extracted from kiwi/avocet where it was duplicated. Reads llm.yaml via the same path LLMRouter uses — products can now import detect_byok from cf-core instead of maintaining their own copy.
This commit is contained in:
parent
b52c578911
commit
b21d6acc8e
2 changed files with 27 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
__version__ = "0.16.0"
|
||||
__version__ = "0.16.1"
|
||||
|
||||
try:
|
||||
from circuitforge_core.community import CommunityDB, CommunityPost, SharedStore
|
||||
|
|
|
|||
|
|
@ -312,3 +312,29 @@ class CloudSessionFactory:
|
|||
return session
|
||||
|
||||
return _check
|
||||
|
||||
|
||||
# ── BYOK detection ────────────────────────────────────────────────────────────
|
||||
|
||||
def detect_byok(config_path: Path | None = None) -> bool:
|
||||
"""Return True if at least one enabled non-vision LLM backend is configured.
|
||||
|
||||
Reads the shared llm.yaml that LLMRouter uses. Local (Ollama, vLLM) and
|
||||
API-key backends both count — the policy is "user is supplying compute",
|
||||
regardless of where that compute lives.
|
||||
|
||||
Args:
|
||||
config_path: Override the default config location. Useful in tests.
|
||||
"""
|
||||
import yaml
|
||||
if config_path is None:
|
||||
config_path = Path.home() / ".config" / "circuitforge" / "llm.yaml"
|
||||
try:
|
||||
with open(config_path) as f:
|
||||
cfg = yaml.safe_load(f) or {}
|
||||
return any(
|
||||
b.get("enabled", True) and b.get("type") != "vision_service"
|
||||
for b in cfg.get("backends", {}).values()
|
||||
)
|
||||
except Exception:
|
||||
return False
|
||||
|
|
|
|||
Loading…
Reference in a new issue