[Extensibility 2/4] feat: keyless demo mode — a real first-run answer instead of a 401 (stacked on #259) - #260
Draft
amal66 wants to merge 2 commits into
Draft
Conversation
Replace the per-provider if/else chains in lib/llm/index.ts and the env-var switch in lib/userApiKeys.ts with a provider registry (lib/llm/registry.ts) and an API-key provider table (core/apiKeyProviders.ts). Adding a provider is now a registerProvider()/registerApiKeyProvider() call — no edits to index.ts, models.ts, or userApiKeys.ts required. Ported from the amal66/mike monorepo fork (origin/main, b3166dd); mechanical translation into the backend/ layout. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC
Add a built-in keyless "demo" provider (lib/llm/providers/demo.ts, DEMO_MODEL = "mike-demo") that answers with a canned, context-aware placeholder plus a nudge to configure a key. The chat stream route falls back to it automatically when the chosen model's provider has no env or per-user key (resolveDemoFallback in routes/chat.ts). Frontend: "Demo (no key needed)" entry in the model dropdown, silent demo fallback on send in ChatInput (replaces the blocking ApiKeyMissingPopup), and a dismissible global ApiKeyBanner while no provider key is configured. Ported from the amal66/mike monorepo fork (origin/main, b3166dd); mechanical translation into the backend/ + frontend/ layout. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC
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
A brand-new instance answers its first question with a canned, clearly-labelled, context-aware reply — plus a nudge toward Settings → API Keys — instead of a raw provider 401. First-run users and zero-setup demos work with no API keys at all, entirely offline.
Changes
Backend:
providers/demo.ts(new, registered via the registry),DEMO_MODEL = "mike-demo", andresolveDemoFallback()inroutes/chat.ts— a request for a keyless provider runs on the demo model instead of failing.Frontend: "Demo (no key needed)" entry in the model picker;
ChatInputfalls back to demo instead of the blocking key popup; dismissibleApiKeyBannershown while no provider key is configured.Why
Today a fresh install hits a hard error on the very first message. This is the single highest-friction moment for new users and demos; after this PR the first message always answers, labelled as demo output, and documents never leave the workspace until a real key is added.
Testing
On this branch: backend
npm test279 passed; frontendnpm test38 passed,eslint0 errors,next buildclean.Provenance
Mechanical port of the demo mode running in amal66/mike (main), including its keyless-fallback fixes. Full provenance in amal66#28.
🤖 Generated with Claude Code