(raw: string)
| 23 | * makes the free-text field feel honest instead of opaque. |
| 24 | */ |
| 25 | export function classifyModelRef(raw: string): ModelRefKind { |
| 26 | const trimmed = raw.trim(); |
| 27 | if (trimmed.length === 0) { |
| 28 | return { kind: "unknown" }; |
| 29 | } |
| 30 | if (trimmed.startsWith("hf://")) { |
| 31 | return { kind: "huggingface", ref: trimmed }; |
| 32 | } |
| 33 | // Local path heuristics. Conservative: only mark as path when there are |
| 34 | // unambiguous signals (leading separator, home shortcut, .gguf extension). |
| 35 | const looksLikePath = |
| 36 | trimmed.startsWith("/") || |
| 37 | trimmed.startsWith("./") || |
| 38 | trimmed.startsWith("../") || |
| 39 | trimmed.startsWith("~") || |
| 40 | trimmed.toLowerCase().endsWith(".gguf"); |
| 41 | if (looksLikePath) { |
| 42 | return { kind: "local-path", path: trimmed }; |
| 43 | } |
| 44 | return { kind: "catalog", name: trimmed }; |
| 45 | } |
| 46 | |
| 47 | /** Short label for the inline hint, e.g. "Looks like a catalog name". */ |
| 48 | export function modelRefHintLabel(kind: ModelRefKind): string | null { |
no outgoing calls
no test coverage detected