1+ import process from "process" ;
12import { CommandModule } from "yargs" ;
23import chalk from "chalk" ;
4+ import fs from "fs-extra" ;
35import { readGgufFileInfo } from "../../../../gguf/readGgufFileInfo.js" ;
46import { resolveHeaderFlag } from "../../../utils/resolveHeaderFlag.js" ;
57import { withCliCommandDescriptionDocsUrl } from "../../../utils/withCliCommandDescriptionDocsUrl.js" ;
@@ -17,9 +19,11 @@ import {Llama} from "../../../../bindings/Llama.js";
1719import { getGgufFileTypeName } from "../../../../gguf/utils/getGgufFileTypeName.js" ;
1820import { getPrettyBuildGpuName } from "../../../../bindings/consts.js" ;
1921import withOra from "../../../../utils/withOra.js" ;
20- import { resolveModelDestination } from "../../../../utils/resolveModelDestination.js" ;
22+ import { resolveModelArgToFilePathOrUrl } from "../../../../utils/resolveModelDestination.js" ;
2123import { printModelDestination } from "../../../utils/printModelDestination.js" ;
2224import { toBytes } from "../../../utils/toBytes.js" ;
25+ import { printDidYouMeanUri } from "../../../utils/resolveCommandGgufPath.js" ;
26+ import { isModelUri } from "../../../../utils/parseModelUri.js" ;
2327
2428type InspectEstimateCommand = {
2529 modelPath : string ,
@@ -121,13 +125,23 @@ export const InspectEstimateCommand: CommandModule<object, InspectEstimateComman
121125 if ( contextSizeArg === - 1 ) contextSizeArg = undefined ;
122126 if ( contextSizeArg === - 2 ) contextSizeArg = "train" ;
123127
124- const resolvedModelDestination = resolveModelDestination ( ggufPath ) ;
125- const resolvedGgufPath = resolvedModelDestination . type == "file"
126- ? resolvedModelDestination . path
127- : resolvedModelDestination . url ;
128-
129128 const headers = resolveHeaderFlag ( headerArg ) ;
130129
130+ const [ resolvedModelDestination , resolvedGgufPath ] = isModelUri ( ggufPath )
131+ ? await withOra ( {
132+ loading : chalk . blue ( "Resolving model URI" ) ,
133+ success : chalk . blue ( "Resolved model URI" ) ,
134+ fail : chalk . blue ( "Failed to resolve model URI" ) ,
135+ noSuccessLiveStatus : true
136+ } , ( ) => resolveModelArgToFilePathOrUrl ( ggufPath , headers ) )
137+ : await resolveModelArgToFilePathOrUrl ( ggufPath , headers ) ;
138+
139+ if ( resolvedModelDestination . type === "file" && ! await fs . pathExists ( resolvedGgufPath ) ) {
140+ console . error ( `${ chalk . red ( "File does not exist:" ) } ${ resolvedGgufPath } ` ) ;
141+ printDidYouMeanUri ( ggufPath ) ;
142+ process . exit ( 1 ) ;
143+ }
144+
131145 const llama = gpu == null
132146 ? await getLlama ( "lastBuild" , {
133147 logLevel : LlamaLogLevel . error
0 commit comments