char-fork/llama.cpp

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

Aleksander Grygierui: Stores split refactor (#27240)521a64cd0

char/aliceai-t5-moe
1.8 KiB49 linesraw
1/**
2 * PropsService - Fetches server properties from /props
3 *
4 * Returns global server settings and capabilities, including per-model
5 * modalities in MODEL mode. No reactive state; consumed by serverStore and
6 * the model props manager.
7 */
8
9import { apiFetchWithParams } from '$lib/utils';
10
11export class PropsService {
12	/**
13	 * Fetches global server properties from the `/props` endpoint.
14	 * In MODEL mode, returns modalities for the single loaded model.
15	 * In ROUTER mode, returns server-wide settings without model-specific modalities.
16	 *
17	 * @param autoload - If false, prevents automatic model loading (default: false)
18	 * @returns Server properties including default generation settings and capabilities
19	 * @throws {Error} If the request fails or returns invalid data
20	 */
21	static async fetch(autoload = false): Promise<ApiLlamaCppServerProps> {
22		const params: Record<string, string> = {};
23
24		if (!autoload) {
25			params.autoload = 'false';
26		}
27
28		return apiFetchWithParams<ApiLlamaCppServerProps>('./props', params, { authOnly: true });
29	}
30
31	/**
32	 * Fetches server properties for a specific model (ROUTER mode only).
33	 * Required in ROUTER mode because global `/props` does not include per-model modalities.
34	 *
35	 * @param modelId - The model ID to fetch properties for
36	 * @param autoload - If false, prevents automatic model loading (default: false)
37	 * @returns Server properties specific to the requested model
38	 * @throws {Error} If the request fails, model not found, or model not loaded
39	 */
40	static async fetchForModel(modelId: string, autoload = false): Promise<ApiLlamaCppServerProps> {
41		const params: Record<string, string> = { model: modelId };
42
43		if (!autoload) {
44			params.autoload = 'false';
45		}
46
47		return apiFetchWithParams<ApiLlamaCppServerProps>('./props', params, { authOnly: true });
48	}
49}