fix(xiaoyuzhou): correct groq-api-key→groq-key in doctor hint and fix check() reading config after configure (#129)
Fixes #128 Two bugs: 1. doctor warn message said 'agent-reach configure groq-api-key' but the actual CLI arg is 'groq-key' (see cli.py:75 choices list and :993 handler). Same typo existed in cli.py _install_xiaoyuzhou_deps() output. 2. check() had a logic flaw: the inner 'if not has_key' was nested inside 'if not os.environ.get(...)', so when GROQ_API_KEY env var was absent but config.json read succeeded, the outer condition never triggered the warning. Refactored to a flat has_key variable — cleaner and correct. Verified: 36/36 tests pass, manual unit tests confirm warn uses 'groq-key' and ok is returned when groq_api_key is present in config.json. Co-authored-by: 小白(Agent) <neo@agent-reach.dev>
This commit is contained in:
@@ -35,11 +35,10 @@ class XiaoyuzhouChannel(Channel):
|
|||||||
" 或手动复制 transcribe.sh 到 ~/.agent-reach/tools/xiaoyuzhou/"
|
" 或手动复制 transcribe.sh 到 ~/.agent-reach/tools/xiaoyuzhou/"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check GROQ_API_KEY
|
# Check GROQ_API_KEY — prefer env var, fall back to config file
|
||||||
if not os.environ.get("GROQ_API_KEY"):
|
has_key = bool(os.environ.get("GROQ_API_KEY"))
|
||||||
# Check if saved in config
|
if not has_key:
|
||||||
config_path = os.path.expanduser("~/.agent-reach/config.json")
|
config_path = os.path.expanduser("~/.agent-reach/config.json")
|
||||||
has_key = False
|
|
||||||
if os.path.isfile(config_path):
|
if os.path.isfile(config_path):
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
@@ -52,7 +51,7 @@ class XiaoyuzhouChannel(Channel):
|
|||||||
return "warn", (
|
return "warn", (
|
||||||
"需要配置 Groq API Key(免费)。步骤:\n"
|
"需要配置 Groq API Key(免费)。步骤:\n"
|
||||||
" 1. 注册 https://console.groq.com\n"
|
" 1. 注册 https://console.groq.com\n"
|
||||||
" 2. 运行: agent-reach configure groq-api-key gsk_xxxxx"
|
" 2. 运行: agent-reach configure groq-key gsk_xxxxx"
|
||||||
)
|
)
|
||||||
|
|
||||||
return "ok", "完整可用(播客下载 + Whisper 转录)"
|
return "ok", "完整可用(播客下载 + Whisper 转录)"
|
||||||
|
|||||||
+1
-1
@@ -503,7 +503,7 @@ def _install_xiaoyuzhou_deps():
|
|||||||
print(" ✅ Groq API key configured")
|
print(" ✅ Groq API key configured")
|
||||||
else:
|
else:
|
||||||
print(" -- Groq API key not set. Get free key at https://console.groq.com")
|
print(" -- Groq API key not set. Get free key at https://console.groq.com")
|
||||||
print(" Then run: agent-reach configure groq-api-key gsk_xxxxx")
|
print(" Then run: agent-reach configure groq-key gsk_xxxxx")
|
||||||
|
|
||||||
|
|
||||||
def _install_weibo_deps():
|
def _install_weibo_deps():
|
||||||
|
|||||||
Reference in New Issue
Block a user