Files
skills/image-service/scripts/load_config_simple.py
T
hmo 04db423416 Initial commit: skills library
- 70 skills with code and documentation
- Add .gitignore (ignore __pycache__, output/, temp/, venv/)
- Clean up test intermediates and caches
2026-04-26 19:27:40 +08:00

43 lines
987 B
Python

#!/usr/bin/env python3
"""
配置加载工具 - 简化版本
从 skill config/settings.json 读取配置
"""
import os
import json
from pathlib import Path
def load_config(config_path=None):
"""从配置文件加载配置"""
if config_path is None:
config_path = Path(__file__).parent.parent / "config" / "settings.json"
if config_path.exists():
with open(config_path, "r", encoding="utf-8") as f:
config = json.load(f)
return config
print(f"Config file not found: {config_path}")
return None
def get_api_key(config_path=None):
"""获取API Key"""
config = load_config(config_path)
if config:
return config.get("image_api", {}).get("key")
return None
if __name__ == "__main__":
import sys
config_path = sys.argv[1] if len(sys.argv) > 1 else None
key = get_api_key(config_path)
if key:
print(f"API Key: {key[:10]}...{key[-10:]}")
else:
print("No API Key found")