char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Services consolidation refactor (#27239)3dc7285b4

char/aliceai-t5-moe
1.5 KiB65 linesraw
1/**
2 * versionStore - Build version information
3 *
4 * - `build`: llama.cpp build number from `build.json`, embedded at llama.cpp
5 *   build time (LLAMA_BUILD_NUMBER). Shown in the UI when `showBuildVersion`
6 *   is enabled.
7 * - `frontend`: frontend build version from SvelteKit's `_app/version.json`,
8 *   generated by the @vite-pwa/sveltekit plugin. Changes on every build, so
9 *   comparing it against localStorage reliably detects server upgrades.
10 *
11 * In dev mode both fall back to `'dev'`.
12 */
13
14import { browser } from '$app/environment';
15import { base } from '$app/paths';
16
17class VersionStore {
18	build = $state<string>('');
19	frontend = $state<string>('');
20
21	/**
22	 * Fetch the version files. Called by initStores(); order-independent,
23	 * so it runs in the background.
24	 */
25	initialize(): void {
26		if (!browser) return;
27
28		if (import.meta.env.DEV) {
29			this.build = 'dev';
30			this.frontend = 'dev';
31
32			return;
33		}
34
35		void this.load();
36	}
37
38	private async load(): Promise<void> {
39		try {
40			const res = await fetch(`${base}/build.json`, { cache: 'no-store' });
41
42			if (res.ok) {
43				const data = await res.json();
44
45				this.build = data.version ?? '';
46			}
47		} catch {
48			// build.json missing or unreachable - leave as empty string
49		}
50
51		try {
52			const res = await fetch(`${base}/_app/version.json`, { cache: 'no-store' });
53
54			if (res.ok) {
55				const data = await res.json();
56
57				this.frontend = data.version ?? '';
58			}
59		} catch {
60			// version.json missing or unreachable - leave as empty string
61		}
62	}
63}
64
65export const versionStore = new VersionStore();