diff --git a/tools/ui/src/lib/services/models.service.ts b/tools/ui/src/lib/services/models.service.ts index bb1bbd356a..b0fcca0eec 100644 --- a/tools/ui/src/lib/services/models.service.ts +++ b/tools/ui/src/lib/services/models.service.ts @@ -187,8 +187,17 @@ export class ModelsService { // 6. Model name = segments before params; tags = remaining segments after params const pivotIdx = paramsIdx !== MODEL_ID.NOT_FOUND ? paramsIdx : segments.length; + const modelSegments = segments.slice(0, pivotIdx); - result.modelName = segments.slice(0, pivotIdx).join(MODEL_ID.SEGMENT_SEPARATOR) || null; + // strip trailing container-format segments (e.g. GGUF) from the model name + while ( + modelSegments.length > 0 && + MODEL_ID.IGNORED_SEGMENTS.has(modelSegments[modelSegments.length - 1].toUpperCase()) + ) { + modelSegments.pop(); + } + + result.modelName = modelSegments.join(MODEL_ID.SEGMENT_SEPARATOR) || null; if (paramsIdx !== MODEL_ID.NOT_FOUND) { result.tags = segments.slice(paramsIdx + 1).filter((_, relIdx) => { diff --git a/tools/ui/tests/unit/model-id-parser.test.ts b/tools/ui/tests/unit/model-id-parser.test.ts index 3dac1dfaba..5903f196ab 100644 --- a/tools/ui/tests/unit/model-id-parser.test.ts +++ b/tools/ui/tests/unit/model-id-parser.test.ts @@ -97,6 +97,38 @@ describe('parseModelId', () => { }); }); + it('strips trailing container format segments from model names', () => { + expect(parseModelId('unsloth/DeepSeek-V4-Flash-0731-GGUF:Q2_K_XL')).toStrictEqual({ + activatedParams: null, + modelName: 'DeepSeek-V4-Flash-0731', + orgName: 'unsloth', + params: null, + quantization: 'Q2_K_XL', + raw: 'unsloth/DeepSeek-V4-Flash-0731-GGUF:Q2_K_XL', + tags: [] + }); + + expect(parseModelId('unsloth/Laguna-S-2.1-GGUF:Q4_K_XL')).toStrictEqual({ + activatedParams: null, + modelName: 'Laguna-S-2.1', + orgName: 'unsloth', + params: null, + quantization: 'Q4_K_XL', + raw: 'unsloth/Laguna-S-2.1-GGUF:Q4_K_XL', + tags: [] + }); + + expect(parseModelId('org/Model-Name-GGUF')).toStrictEqual({ + activatedParams: null, + modelName: 'Model-Name', + orgName: 'org', + params: null, + quantization: null, + raw: 'org/Model-Name-GGUF', + tags: [] + }); + }); + it('handles real-world examples correctly', () => { expect(parseModelId('meta-llama/Llama-3.1-8B')).toStrictEqual({ activatedParams: null,