]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
ui: strip path and weight extension from model id in single model mode (#25137)
authorPascal <redacted>
Fri, 3 Jul 2026 15:32:48 +0000 (17:32 +0200)
committerGitHub <redacted>
Fri, 3 Jul 2026 15:32:48 +0000 (17:32 +0200)
tools/ui/src/lib/constants/model-id.ts
tools/ui/src/lib/services/models.service.ts

index ee314d16744e0e4396eab4c54ea60ae2375e337e..ab7932240e49e2d1c7e82b1ac992de7141c17ff8 100644 (file)
@@ -37,3 +37,8 @@ export const MODEL_ACTIVATED_PARAMS_RE = /^[Aa]\d+(\.\d+)?[BbMmKkTt]$/;
  * Container format segments to exclude from tags (every model uses these).
  */
 export const MODEL_IGNORED_SEGMENTS = new Set(['GGUF', 'GGML']);
+
+/**
+ * Matches a trailing weight file extension, e.g. `model.gguf` -> `model`.
+ */
+export const MODEL_WEIGHT_EXTENSION_RE = /\.(gguf|ggml)$/i;
index 209bd7caba5239d7565d3cfe92945787c979f35a..9574da59ef9f6a0b4e56910f97fa60e2f9b48343 100644 (file)
@@ -1,5 +1,5 @@
 import { ServerModelStatus } from '$lib/enums';
-import { apiFetch, apiPost } from '$lib/utils';
+import { apiFetch, apiPost, normalizeModelName } from '$lib/utils';
 import type { ParsedModelId } from '$lib/types/models';
 import {
        MODEL_QUANTIZATION_SEGMENT_RE,
@@ -7,6 +7,7 @@ import {
        MODEL_PARAMS_RE,
        MODEL_ACTIVATED_PARAMS_RE,
        MODEL_IGNORED_SEGMENTS,
+       MODEL_WEIGHT_EXTENSION_RE,
        MODEL_ID_NOT_FOUND,
        MODEL_ID_ORG_SEPARATOR,
        MODEL_ID_SEGMENT_SEPARATOR,
@@ -139,15 +140,19 @@ export class ModelsService {
                        tags: []
                };
 
+               // strip directory path and weight extension so a bare `-m /path/file.gguf`
+               // parses like a clean repo id; the HF `org/model` form is preserved
+               const source = normalizeModelName(modelId).replace(MODEL_WEIGHT_EXTENSION_RE, '');
+
                // 1. Extract colon-separated quantization (e.g. `model:Q4_K_M`)
-               const colonIdx = modelId.indexOf(MODEL_ID_QUANTIZATION_SEPARATOR);
+               const colonIdx = source.indexOf(MODEL_ID_QUANTIZATION_SEPARATOR);
                let modelPath: string;
 
                if (colonIdx !== MODEL_ID_NOT_FOUND) {
-                       result.quantization = modelId.slice(colonIdx + 1) || null;
-                       modelPath = modelId.slice(0, colonIdx);
+                       result.quantization = source.slice(colonIdx + 1) || null;
+                       modelPath = source.slice(0, colonIdx);
                } else {
-                       modelPath = modelId;
+                       modelPath = source;
                }
 
                // 2. Extract org name (e.g. `org/model` -> org = "org")