feat: add AI model selection dropdown with per-model completion params - #248
Merged
Conversation
cjot
force-pushed
the
feat/add-model-selection
branch
from
July 28, 2026 20:03
b906f36 to
509a09e
Compare
Add a model <select> dropdown alongside 'Download AI model' in the
chat onboarding UI. Models carry their own completionParams so the
worker has no model-specific branching.
Model configuration (webgpu-provider.ts):
- ModelOption type with id, label, description, vramMb, completionParams
- AVAILABLE_MODELS array: Qwen2.5-0.5B (~945 MB, default), Qwen3-1.7B (~2 GB)
- Qwen3-1.7B passes extra_body: { enable_thinking: false } automatically
- WebGPUProvider constructor accepts ModelOption instead of raw string
Web Worker (ai.worker.ts):
- Stores completionParams per-session, merged into every completion via spread
- Zero model-specific conditionals
UI (ChatPanel.tsx, App.tsx):
- <select> dropdown in onboarding when status === 'idle'
- selectedModel state wired through ChatPanel props to handleAiDownload
Production bug fix:
- AssumptionsList and AffectedDefinitionsList now accept | undefined and guard
before calling .length (conversation API can omit these fields)
- Same defense applied in App.tsx via ?? [] fallbacks
cjot
force-pushed
the
feat/add-model-selection
branch
from
July 28, 2026 20:06
509a09e to
55b1e90
Compare
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
Adds a model selector dropdown to the assistant onboarding UI so users can choose which WebLLM model to download before clicking "Download AI model".
Changes
Model configuration (
web/src/ai/webgpu-provider.ts)ModelOptioninterface withid,label,description,vramMb, and optionalcompletionParamsAVAILABLE_MODELSarray with two entries:completionParams: { extra_body: { enable_thinking: false } }WebGPUProviderconstructor now acceptsModelOptioninstead of a raw stringcompletionParamsthrough theAiWorkerRequestWeb Worker (
web/src/ai/ai.worker.ts)completionParamson init, merges into every completion request via spreadUI (
web/src/ai/ChatPanel.tsx,web/src/App.tsx)<select>dropdown shown in the onboarding section whenstatus === 'idle'selectedModelstate inApp.tsx, passed down as propshandleAiDownloadlooks up the matchingModelOptionand passes it tonew WebGpuProvider(config)Styles (
web/src/style.css).chat-model-selectstyled to match the existing button aestheticTesting
npm run check(tsc) — cleannpm test(vitest) — 353 passed, 4 pre-existing failures inApp.test.tsx(missingassumptionsin mock data, unrelated to these changes)ruff format/ruff check— clean