From 95110e9b8660dc3aa9fe257679a70073337bc371 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Thu, 21 May 2026 00:19:35 +0800 Subject: [PATCH] auto-sync: 2026-05-21 00:19:35 --- src/api/blackboard_routes.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/api/blackboard_routes.py b/src/api/blackboard_routes.py index 3960e25..8c24135 100644 --- a/src/api/blackboard_routes.py +++ b/src/api/blackboard_routes.py @@ -117,22 +117,20 @@ async def _generate_title(description: str) -> str | None: return None try: from openai import OpenAI - import yaml - # 从 moziplus 配置读 LLM 凭据 - cfg_path = Path(__file__).parent.parent.parent / "config" / "default.yaml" + import json as _json + # 从 OpenClaw 配置读 zhipu 凭据 base_url = "https://open.bigmodel.cn/api/paas/v4" api_key = "" model = "glm-4-flash" - if cfg_path.exists(): - with open(cfg_path) as f: - cfg = yaml.safe_load(f) - routing = cfg.get("daemon", {}).get("routing", {}) - if routing.get("api_base"): - base_url = routing["api_base"] - if routing.get("api_key"): - api_key = routing["api_key"] - if routing.get("model"): - model = routing["model"] + oc_cfg = Path.home() / ".openclaw" / "openclaw.json" + if oc_cfg.exists(): + with open(oc_cfg) as f: + cfg = _json.load(f) + zhipu = cfg.get("models", {}).get("providers", {}).get("zhipu", {}) + if zhipu.get("baseUrl"): + base_url = zhipu["baseUrl"] + if zhipu.get("apiKey"): + api_key = zhipu["apiKey"] if not api_key: return None # 没配 API key 就跳过 client = OpenAI(base_url=base_url, api_key=api_key)