Files
CatoandClaude Opus 5 153e03769d fix(example): the reference code shipped a dead model id and three habits worth not copying (#37)
`CompleteFn` is deliberately bring-your-own-provider, which makes this
example the file people copy — and a copied mistake is the expensive
kind. A fleet-wide audit (2026-09-06) found this example teaching all
three of the defects it then found in production clients.

DEAD BY DEFAULT. The default model was `llama-3.3-70b-versatile`, which
Groq retired with the rest of the llama-3 family. Verified live
2026-09-07: 404 model_not_found. Anyone who followed the README with a
Groq key got a broken example and no way to tell why — and the same id
sat in .env.example, on the line a reader is most likely to uncomment.
It is a LIST now, tried in order, because that is the only shape that
survives a vendor's release notes. AI_FORMS_MODEL still wins, and may
itself be comma-separated.

AN EMPTY HTTP 200 WAS AN ANSWER. `content ?? ''` returned the empty
string as though the model had spoken. Some models return exactly that
after spending their whole budget on hidden reasoning, and here it
becomes "the assistant filled in nothing" with no error to explain it.
Now a failure that moves to the next model.

NO DEADLINE. A provider that accepted the connection and then went quiet
held the form open forever, and the next model was never reached. Each
attempt now gets its OWN deadline — a shared one is spent by the first
model and leaves the rest with an already-expired signal, which is worse
than none.

Failures now name every model tried, not just the last: "the key is
dead" and "one id rotted" used to read identically.

Still dependency-free, on purpose — the example exists to show what
CompleteFn is. It points at @bitbaum/ai-kit's complete() for anyone who
would rather not hand-roll this, but being dependency-free is not a
licence to demonstrate the wrong thing.

verify green; the example app typechecks.


Claude-Session: https://claude.ai/code/session_01NHDLTKGirKU7He8q2YR2y4

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 23:55:21 +00:00

12 lines
591 B
Bash

# Optional. With no key the example runs on a deterministic offline pattern
# matcher and says so in the UI. Set either one for a real model.
# GROQ_API_KEY=
# OPENAI_API_KEY=
# Optional override, and a COMMA-SEPARATED LIST tried in order — because a
# pinned model id rots. This line used to suggest `llama-3.3-70b-versatile`,
# which Groq has since retired: it answers 404 model_not_found (checked live
# 2026-09-07), so anyone who uncommented it got a broken example. Leave it unset
# and the app uses a maintained default list.
# AI_FORMS_MODEL=openai/gpt-oss-120b,openai/gpt-oss-20b