Skip to content

Commit 70ca7b5

Browse files
adding progress bar to loading models but it's not pretty
1 parent 9025a23 commit 70ca7b5

File tree

12 files changed

+73
-34
lines changed

12 files changed

+73
-34
lines changed

APP_CONFIG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
To change the app title from "WebLLM Chat" to something else:
66

7-
1. Edit the `app.config.json` file in the root directory:
7+
1. Edit the `src/app.config.json` file:
88
```json
99
{
1010
"title": "Your Custom Title",
File renamed without changes.

src/lib/components/ChatInterface.svelte

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,23 +1315,7 @@
13151315
</script>
13161316

13171317
<div class="h-full flex overflow-hidden bg-surface-50-900-token">
1318-
<!-- Progress bar - positioned absolutely at top -->
1319-
{#if !$isModelLoaded && $modelLoadingProgress < 100}
1320-
<div
1321-
class="absolute top-0 left-0 z-20 p-4 bg-surface-100-800-token border-b border-surface-300-600-token"
1322-
class:right-0={!showRAGPanel}
1323-
class:right-80={showRAGPanel}
1324-
>
1325-
<div class="flex items-center justify-between mb-2">
1326-
<span class="text-sm font-medium text-surface-700-200-token"
1327-
>Loading Model: {$currentModel}</span
1328-
>
1329-
<span class="text-sm text-surface-700-200-token opacity-70">{$modelLoadingProgress}%</span>
1330-
</div>
1331-
<ProgressBar value={$modelLoadingProgress} max={100} class="mb-2" />
1332-
<p class="text-xs text-surface-700-200-token opacity-70">{$modelLoadingStatus}</p>
1333-
</div>
1334-
{/if}
1318+
<!-- Progress bar removed - now shown in ChatMessage component -->
13351319

13361320
<!-- Main chat area -->
13371321
<div class="flex-1 min-h-0 flex flex-col transition-all duration-300 bg-surface-50-900-token" class:mr-80={showRAGPanel}>

src/lib/components/ChatMessage.svelte

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import { formatTokenCount } from '$lib/utils/tokenCount';
55
import { formatResponseTime } from '$lib/utils/timeFormat';
66
import hljs from 'highlight.js/lib/core';
7+
import { ProgressBar } from '@skeletonlabs/skeleton';
8+
import { modelLoadingProgress, modelLoadingStatus, currentModel, isModelLoaded } from '$lib/stores/models';
79
810
// Import common languages
911
import javascript from 'highlight.js/lib/languages/javascript';
@@ -50,6 +52,17 @@
5052
export let onClose: ((messageId: string) => void) | undefined = undefined;
5153
5254
let isCollapsed = false;
55+
56+
// Check if this is a model loading message
57+
$: isModelLoadingMessage = message.id.startsWith('loading-model-') &&
58+
(message.content.includes('🔄 Switching to') ||
59+
message.content.includes('🤖') ||
60+
message.content.includes('Loading model'));
61+
62+
// Extract model name from loading message
63+
$: loadingModelName = isModelLoadingMessage && message.content.includes('Switching to')
64+
? message.content.match(/Switching to (.+?)\.\.\./)?.[ 1] || $currentModel
65+
: $currentModel;
5366
5467
// For code blocks, we'll estimate token count (rough approximation)
5568
function estimateTokens(text: string): number {
@@ -458,6 +471,22 @@
458471
<div class="prose prose-sm max-w-none text-surface-700-200-token">
459472
{@html formatContent(message.content)}
460473
</div>
474+
475+
<!-- Show loading progress bar for model loading messages -->
476+
{#if isModelLoadingMessage && !$isModelLoaded && $modelLoadingProgress < 100}
477+
<div class="mt-4 p-3 bg-surface-200-700-token rounded-lg">
478+
<div class="flex items-center justify-between mb-2">
479+
<span class="text-sm font-medium text-surface-700-200-token">
480+
Loading Model: {loadingModelName}
481+
</span>
482+
<span class="text-sm text-surface-700-200-token opacity-70">
483+
{$modelLoadingProgress}%
484+
</span>
485+
</div>
486+
<ProgressBar value={$modelLoadingProgress} max={100} class="mb-2" />
487+
<p class="text-xs text-surface-700-200-token opacity-70">{$modelLoadingStatus}</p>
488+
</div>
489+
{/if}
461490
{/if}
462491
{/if}
463492

src/lib/components/FeatureToggle.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,17 @@
4848
<div
4949
class="fixed inset-0 bg-black/50 flex items-center justify-center z-60"
5050
on:click={() => (isVisible = false)}
51+
on:keydown={(e) => e.key === 'Escape' && (isVisible = false)}
52+
role="presentation"
53+
tabindex="-1"
5154
>
5255
<div
5356
class="bg-surface-100-800-token rounded-lg p-6 max-w-md w-full mx-4"
5457
on:click|stopPropagation
58+
on:keydown|stopPropagation
59+
role="dialog"
60+
aria-modal="true"
61+
aria-label="Experimental Features"
5562
>
5663
<div class="flex items-center justify-between mb-4">
5764
<h3 class="text-lg font-semibold">Experimental Features</h3>

src/lib/components/ModelDropdown.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@
122122
class="btn btn-sm variant-ghost-surface"
123123
on:click={() => checkCachedModels()}
124124
title="Refresh cache status"
125+
aria-label="Refresh cache status"
125126
>
126-
<i class="fa fa-refresh"></i>
127+
<i class="fa fa-refresh" aria-hidden="true"></i>
127128
</button>
128129
</div>
129130
</div>

src/lib/components/RAGContext.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
export let isVisible = false;
1313
export let lastQuery: RAGQueryResult | null = null;
14-
export let forceRefresh = 0; // Counter to trigger refresh from parent
14+
export const forceRefresh = 0; // Counter to trigger refresh from parent
1515
export let sendDocumentPreviewToChat: (document: any) => void = () => {};
1616
1717
let documents: RAGDocument[] = [];

src/lib/components/WelcomeGuide.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,21 @@
3232
</script>
3333

3434
{#if isVisible}
35-
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
3635
<div
3736
class="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4"
3837
role="dialog"
3938
aria-modal="true"
4039
aria-labelledby="welcome-title"
4140
on:keydown={handleKeydown}
4241
transition:fade={{ duration: 200 }}
42+
tabindex="-1"
4343
>
4444
<div
4545
class="bg-surface-100-800-token rounded-xl shadow-2xl max-w-4xl max-h-[90vh] overflow-y-auto"
4646
transition:scale={{ duration: 300, easing: quintOut }}
4747
on:click|stopPropagation
48+
on:keydown|stopPropagation
49+
role="document"
4850
>
4951
<!-- Header -->
5052
<div class="sticky top-0 bg-surface-100-800-token border-b border-surface-300-600-token p-6">

src/lib/config/app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import appConfigJson from '../../../app.config.json';
1+
import appConfigJson from '../../app.config.json';
22

33
export const appConfig = {
44
title: appConfigJson.title,

src/lib/stores/models.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ export const MODELS: ModelInfo[] = [
4141
description: '🦙 Llama 3.2 3B - Great for general conversations',
4242
context_length: 131072
4343
},
44-
{
45-
model_id: 'Llama-3.2-3B-Instruct-q4f16_1-1k-MLC',
46-
vram_required_MB: 2048,
47-
low_resource_required: false,
48-
description: '🦙 Llama 3.2 3B with 1M context - Extended conversations',
49-
context_length: 1048576
50-
},
5144
{
5245
model_id: 'Qwen2.5-3B-Instruct-q4f16_1-MLC',
5346
vram_required_MB: 2048,
@@ -176,6 +169,10 @@ export function setModelDownloaded(modelId: string) {
176169
export async function checkCachedModels(): Promise<void> {
177170
console.log('🔍 Checking cached models...');
178171
const { webLLMService } = await import('../utils/webllm');
172+
173+
// Log available models from WebLLM
174+
await webLLMService.getAvailableModels();
175+
179176
const cached = new Set<string>();
180177

181178
for (const model of MODELS) {

0 commit comments

Comments
 (0)