fix(groq): use Config class instead of hardcoded config.json (#136)

Config class writes YAML (config.yaml), but xiaoyuzhou.py, cli.py, and
transcribe.sh were hardcoded to read config.json (JSON format). Users who
configured groq-key via 'agent-reach configure' would not have their key
detected because the wrong file was being read.

Fixes #128 (related to config loading)

Co-authored-by: Panniantong <panniantong@users.noreply.github.com>
This commit is contained in:
Pnant
2026-03-10 14:21:34 +08:00
committed by GitHub
parent f5f4dea075
commit 6737ba6dbd
3 changed files with 11 additions and 22 deletions
+3 -3
View File
@@ -9,11 +9,11 @@ URL="${1:?用法: bash transcribe.sh <小宇宙链接> [输出文件路径]}"
OUTPUT="${2:-/tmp/podcast_transcript.txt}"
TMPDIR="/tmp/xiaoyuzhou_$$"
# Try env var first, then agent-reach config
# Try env var first, then agent-reach config.yaml
if [ -z "$GROQ_API_KEY" ]; then
CONFIG_FILE="$HOME/.agent-reach/config.json"
CONFIG_FILE="$HOME/.agent-reach/config.yaml"
if [ -f "$CONFIG_FILE" ]; then
GROQ_API_KEY=$(python3 -c "import json; print(json.load(open('$CONFIG_FILE')).get('groq_api_key',''))" 2>/dev/null || true)
GROQ_API_KEY=$(python3 -c "import yaml; print((yaml.safe_load(open('$CONFIG_FILE')) or {}).get('groq_api_key',''))" 2>/dev/null || true)
fi
fi
GROQ_API_KEY="${GROQ_API_KEY:?请设置 GROQ_API_KEY 环境变量或运行 agent-reach configure groq-key}"