File size: 1,664 Bytes
31dd200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { apiFetchWithParams } from '$lib/utils';

export class PropsService {
	/**

	 *

	 *

	 * Fetching

	 *

	 *

	 */

	/**

	 * Fetches global server properties from the `/props` endpoint.

	 * In MODEL mode, returns modalities for the single loaded model.

	 * In ROUTER mode, returns server-wide settings without model-specific modalities.

	 *

	 * @param autoload - If false, prevents automatic model loading (default: false)

	 * @returns Server properties including default generation settings and capabilities

	 * @throws {Error} If the request fails or returns invalid data

	 */
	static async fetch(autoload = false): Promise<ApiLlamaCppServerProps> {
		const params: Record<string, string> = {};
		if (!autoload) {
			params.autoload = 'false';
		}

		return apiFetchWithParams<ApiLlamaCppServerProps>('./props', params, { authOnly: true });
	}

	/**

	 * Fetches server properties for a specific model (ROUTER mode only).

	 * Required in ROUTER mode because global `/props` does not include per-model modalities.

	 *

	 * @param modelId - The model ID to fetch properties for

	 * @param autoload - If false, prevents automatic model loading (default: false)

	 * @returns Server properties specific to the requested model

	 * @throws {Error} If the request fails, model not found, or model not loaded

	 */
	static async fetchForModel(modelId: string, autoload = false): Promise<ApiLlamaCppServerProps> {
		const params: Record<string, string> = { model: modelId };
		if (!autoload) {
			params.autoload = 'false';
		}

		return apiFetchWithParams<ApiLlamaCppServerProps>('./props', params, { authOnly: true });
	}
}