Skip to content

Commit b9a6624

Browse files
authored
fix: resolve Groq STT key from model_list when providers.groq is absent (#602)
When users migrate from the legacy `providers` config to the new `model_list` format, voice transcription silently breaks on Telegram, Discord and Slack channels. The gateway was reading the Groq API key exclusively from `cfg.Providers.Groq.APIKey`, which is empty once the key is defined only inside a `model_list` entry. The transcriber was never initialized, so voice messages fell back to a plain `[voice]` placeholder. This fix also scans `model_list` for any entry whose `model` field starts with `groq/` and uses its `api_key` as a fallback, preserving full backward compatibility with the legacy `providers.groq` field.
1 parent c51ceac commit b9a6624

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cmd/picoclaw/cmd_gateway.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"os"
1111
"os/signal"
1212
"path/filepath"
13+
"strings"
1314
"time"
1415

1516
"github.com/sipeed/picoclaw/pkg/agent"
@@ -121,8 +122,17 @@ func gatewayCmd() {
121122
agentLoop.SetChannelManager(channelManager)
122123

123124
var transcriber *voice.GroqTranscriber
124-
if cfg.Providers.Groq.APIKey != "" {
125-
transcriber = voice.NewGroqTranscriber(cfg.Providers.Groq.APIKey)
125+
groqAPIKey := cfg.Providers.Groq.APIKey
126+
if groqAPIKey == "" {
127+
for _, mc := range cfg.ModelList {
128+
if strings.HasPrefix(mc.Model, "groq/") && mc.APIKey != "" {
129+
groqAPIKey = mc.APIKey
130+
break
131+
}
132+
}
133+
}
134+
if groqAPIKey != "" {
135+
transcriber = voice.NewGroqTranscriber(groqAPIKey)
126136
logger.InfoC("voice", "Groq voice transcription enabled")
127137
}
128138

0 commit comments

Comments
 (0)