feat: adopt ai-kit's tryChain + createHealthTracker; add /api/health - #26
Merged
Conversation
hirnli has already been silently taken down once by a single retired Groq model id -- every route and script here called ONE pinned model, once, with nothing between that and total failure. This closes that gap the same way botsmann's did this session. - scripts/lib/groq-client.ts: callGroq now walks ai-kit's fallback chain for Groq via tryChain when the caller leaves the model unspecified, instead of calling one hardcoded id. GROQ_MODELS' alias table is now derived FROM that chain rather than hardcoding the same ids a second time. An explicit model/alias is still honoured as-is and alone, unchanged. - src/app/api/ai/gesuch-section/route.ts: this route hand-rolled its OWN separate Groq fetch, with its own hardcoded model id -- a second copy of exactly what groq-client.ts already did, despite that file's own docstring saying it was "extracted from" this route. Now calls callGroq directly; ~50 lines of duplicated fetch/error-handling code deleted. - src/lib/llm-health.ts + src/app/api/health/route.ts (both new): hirnli had no health endpoint at all. Records success/failure around the gesuch-section route via ai-kit's createHealthTracker, exposed at /api/health (liveness) and /api/health?strict=1 (readiness -- 503 only when the LLM chain itself is down, never on a restart-proof problem). ai-kit bumped to v0.5.0. Full verify green: lint, lint:umlauts, typecheck, 889 tests (17 new), production build. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/lib/groq-client.ts:callGroqnow walksai-kit's fallback chain for Groq (tryChain) when no explicit model is given, instead of calling one pinned id once.GROQ_MODELS' alias table is now derived from that chain rather than hardcoding the same ids a second time.src/app/api/ai/gesuch-section/route.ts: deleted its own separate hand-rolled Groq fetch (a second copy of exactly whatgroq-client.tsalready did — its own docstring says it was "extracted from" this route, but the route was never switched over) and now callscallGroqdirectly.src/lib/llm-health.ts(wrapsai-kit'screateHealthTracker) +src/app/api/health/route.ts— hirnli had no health endpoint at all./api/healthfor liveness,/api/health?strict=1for readiness (503 only when the LLM chain is actually down).ai-kitbumped to v0.5.0.This closes the same gap this session already fixed in botsmann: hirnli was flagged by a fleet-wide AI-tooling audit as having zero shared-package adoption with no stated reason to skip, and the smallest hand-rolled surface in the fleet.
Test plan
lint:umlauts, typecheck, 889 tests (17 new — fallback-chain demotion, chain-exhaustion, explicit-model-stays-single-shot, health state machine), production build