Fix --list-models in JS vision sample#826
Conversation
The --list-models branch in samples/js/web-server-responses-vision-example/app.js called manager.catalog.listModels(), which does not exist on the SDK catalog (the correct method is getModels()). It also awaited variant.isCached as if it were an async method, but it is a synchronous getter property. This fixes both call sites of listModels() and the isCached() invocation so that --list-models actually prints the vision-model table instead of throwing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes the --list-models code path in the JavaScript vision sample (samples/js/web-server-responses-vision-example/app.js). The sample called manager.catalog.listModels(), which does not exist on the SDK catalog, and awaited v.isCached as though it were an async method. Both bugs would cause --list-models to throw instead of printing the vision-model table. The corrections align the sample with the actual foundry-local-sdk API.
I verified against the SDK source that:
Catalog.getModels()exists (sdk/js/src/catalog.ts:149) and there is nolistModels()method.IModel.isCachedis a synchronous boolean getter (sdk/js/src/imodel.ts:11), so it must not be invoked or awaited.
Both listModels() call sites (lines 52 and 101) and the single await v.isCached() (line 88) were correctly updated, and no other affected call sites remain.
Changes:
- Replace
manager.catalog.listModels()withmanager.catalog.getModels()at both call sites. - Replace
(await v.isCached())with the synchronous getterv.isCached.
The
--list-modelsbranch insamples/js/web-server-responses-vision-example/app.jscalledmanager.catalog.listModels(), which does not exist on the SDK catalog (the correct method isgetModels()). It also awaitedvariant.isCachedas if it were an async method, but it is a synchronous getter property.This PR fixes both call sites of
listModels()and theisCached()invocation so that--list-modelsactually prints the vision-model table instead of throwing.Tested locally against the Qwen3.5 VL family with
node app.js --list-models— output now renders the expected table.