feat(voice): split dictations with Groq when it is configured

Gemma through the Gemini API answered 500 or timed out on most calls, so
dictated lists fell back to splitting on commas and "y" ("Azúcar leche y
café" became two items). With GROQ_API_KEY set the API now asks Groq
(openai/gpt-oss-120b by default), which answers in about a second; Gemini
stays as the provider when only its key is set.

The HTTP call, its deadline and the single retry on 5xx move to
lib/text-generator.ts and are shared by both clients.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-10-29 11:04:13 -03:00
parent cc0611b6a0
commit 6830c827d7
13 changed files with 311 additions and 87 deletions

View File

@@ -7,8 +7,8 @@ Biome as the only JS/TS tool and the text Bun lockfile committed. It is deployed
Dokploy (`docker-compose.yml`); there is no hosted CI.
Not done yet: product features are just starting (sign-up, password recovery with an emailed OTP, shopping lists, list items and invitations exist;
there is no Google login and no email verification; the `voice` module splits dictated text with Gemma 4
through the Gemini API). The `health` module is the reference example.
there is no Google login and no email verification; the `voice` module splits dictated text with Groq, or Gemma 4
through the Gemini API when Groq is not configured). The `health` module is the reference example.
## Stack (source of truth: `STACK.md`)
@@ -100,7 +100,8 @@ Run from the repo root. Verification order is `build`, then `lint` → `typechec
`apps/web/nginx.conf`, which also proxies `/api/*` to `http://superlist-api:4100` (re-resolved through
Docker's DNS, so API redeploys don't leave nginx on a stale IP). Required env vars are interpolated
by Compose (`DATABASE_URL`, `BETTER_AUTH_SECRET`, `BETTER_AUTH_URL`, `CORS_ORIGIN`, `WEB_APP_URL`); set them
in Dokploy. The dictation variables (`GEMINI_API_KEY`, `GEMINI_MODEL`, `GEMINI_TIMEOUT_MS`) are optional and
in Dokploy. The dictation variables (`GROQ_API_KEY`, `GROQ_MODEL`, `GROQ_TIMEOUT_MS`, `GEMINI_API_KEY`, `GEMINI_MODEL`,
`GEMINI_TIMEOUT_MS`) are optional (Groq wins when its key is set) and
backend-only — never give them a `VITE_` prefix, or Vite would ship the key in the browser bundle. There is no hosted CI.
- Generated files are gitignored and must never be edited by hand: `apps/web/src/routeTree.gen.ts`,
`apps/api/src/generated/`.