feat(网关): 接口4 改由网关本机直接调豆包视觉模型,不再代理到 worker
- gateway/app.py: 接口4 handler 改为直接调用 face_features 模块 - face_features.py: API Key 读取支持 gateway/config.json - gateway/config.example.json: 增加 ark_api_key 配置项
This commit is contained in:
+12
-8
@@ -55,17 +55,21 @@ _client = None
|
||||
|
||||
|
||||
def _load_api_key() -> str | None:
|
||||
"""ARK_API_KEY 环境变量优先,否则读 worker_config.json 的 ark_api_key。"""
|
||||
"""ARK_API_KEY 环境变量优先,否则读 worker_config.json / gateway/config.json 的 ark_api_key。"""
|
||||
key = os.getenv("ARK_API_KEY")
|
||||
if key:
|
||||
return key
|
||||
cfg = os.path.join(os.path.dirname(__file__), "worker_config.json")
|
||||
if os.path.isfile(cfg):
|
||||
try:
|
||||
with open(cfg, encoding="utf-8") as f:
|
||||
return json.load(f).get("ark_api_key")
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.warning("读取 worker_config.json ark_api_key 失败:%s", e)
|
||||
base = os.path.dirname(__file__)
|
||||
for cfg_name in ("worker_config.json", "gateway/config.json"):
|
||||
cfg = os.path.join(base, cfg_name)
|
||||
if os.path.isfile(cfg):
|
||||
try:
|
||||
with open(cfg, encoding="utf-8") as f:
|
||||
v = json.load(f).get("ark_api_key")
|
||||
if v:
|
||||
return v
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.warning("读取 %s ark_api_key 失败:%s", cfg_name, e)
|
||||
return None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user