mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 17:51:22 +00:00
fix(model-ref): treat LM Studio/Ollama @q*/@4bit suffixes as model-id
This commit is contained in:
committed by
Peter Steinberger
parent
d4da45c202
commit
5208a85afe
@@ -66,4 +66,23 @@ describe("splitTrailingAuthProfile", () => {
|
||||
profile: "work",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps @q* quant suffixes in model ids", () => {
|
||||
expect(splitTrailingAuthProfile("lmstudio-mb-pro/gemma-4-31b-it@q8_0")).toEqual({
|
||||
model: "lmstudio-mb-pro/gemma-4-31b-it@q8_0",
|
||||
});
|
||||
});
|
||||
|
||||
it("supports auth profiles after @q* quant suffixes", () => {
|
||||
expect(splitTrailingAuthProfile("lmstudio-mb-pro/gemma-4-31b-it@q8_0@work")).toEqual({
|
||||
model: "lmstudio-mb-pro/gemma-4-31b-it@q8_0",
|
||||
profile: "work",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps @4bit/@8bit quant suffixes in model ids", () => {
|
||||
expect(splitTrailingAuthProfile("lmstudio-mb-pro/gemma-4-31b@4bit")).toEqual({
|
||||
model: "lmstudio-mb-pro/gemma-4-31b@4bit",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,6 +14,9 @@ export function splitTrailingAuthProfile(raw: string): {
|
||||
}
|
||||
|
||||
const versionSuffix = trimmed.slice(profileDelimiter + 1);
|
||||
|
||||
// Keep well-known "version" suffixes (ex: @20251001) as part of the model id,
|
||||
// but allow an auth profile suffix *after* them (ex: ...@20251001@work).
|
||||
if (/^\d{8}(?:@|$)/.test(versionSuffix)) {
|
||||
const nextDelimiter = trimmed.indexOf("@", profileDelimiter + 9);
|
||||
if (nextDelimiter < 0) {
|
||||
@@ -22,6 +25,20 @@ export function splitTrailingAuthProfile(raw: string): {
|
||||
profileDelimiter = nextDelimiter;
|
||||
}
|
||||
|
||||
// Keep local model quant suffixes (common in LM Studio/Ollama catalogs) as part
|
||||
// of the model id. These often use '@' (ex: gemma-4-31b-it@q8_0) which would
|
||||
// otherwise be misinterpreted as an auth profile delimiter.
|
||||
//
|
||||
// If an auth profile is needed, it can still be specified as a second suffix:
|
||||
// lmstudio/foo@q8_0@work
|
||||
if (/^(?:q\d+(?:_[a-z0-9]+)*|\d+bit)(?:@|$)/i.test(versionSuffix)) {
|
||||
const nextDelimiter = trimmed.indexOf("@", profileDelimiter + 1);
|
||||
if (nextDelimiter < 0) {
|
||||
return { model: trimmed };
|
||||
}
|
||||
profileDelimiter = nextDelimiter;
|
||||
}
|
||||
|
||||
const model = trimmed.slice(0, profileDelimiter).trim();
|
||||
const profile = trimmed.slice(profileDelimiter + 1).trim();
|
||||
if (!model || !profile) {
|
||||
|
||||
Reference in New Issue
Block a user