MCPcopy Create free account
hub / github.com/Roy3838/Observer / getLocalModelState

Method getLocalModelState

app/src/utils/ModelManager.ts:478–522  ·  view source on GitHub ↗

* Get unified state for a local model by server type. * Returns the current loading/loaded state for the specified engine.

(server: string)

Source from the content-addressed store, hash-verified

476 * Returns the current loading/loaded state for the specified engine.
477 */
478 public getLocalModelState(server: string): LocalModelState {
479 if (server === ModelManager.BROWSER_LOCAL) {
480 const gemmaState = GemmaModelManager.getInstance().getState();
481 return {
482 status: gemmaState.status === 'unloaded' ? 'unloaded'
483 : gemmaState.status === 'loading' ? 'loading'
484 : gemmaState.status === 'loaded' ? 'loaded'
485 : 'error',
486 modelId: gemmaState.modelId,
487 error: gemmaState.error,
488 progress: gemmaState.progress.map(p => ({
489 file: p.file,
490 progress: p.progress,
491 loaded: p.loaded,
492 total: p.total,
493 done: p.status === 'done',
494 })),
495 engineInfo: gemmaState.loadSettings ? {
496 type: 'transformers.js',
497 device: gemmaState.loadSettings.device,
498 dtype: gemmaState.loadSettings.dtype,
499 enableThinking: gemmaState.loadSettings.enableThinking ?? false,
500 } : { type: 'transformers.js' },
501 };
502 }
503
504 if (server === ModelManager.LLAMA_CPP_LOCAL && isTauri()) {
505 const nativeState = NativeLlmManager.getInstance().getState();
506 return {
507 status: nativeState.status,
508 modelId: nativeState.modelId,
509 error: nativeState.error,
510 progress: [], // llama.cpp doesn't have file-level progress
511 engineInfo: { type: 'llama.cpp' },
512 };
513 }
514
515 // Default state for unknown server
516 return {
517 status: 'unloaded',
518 modelId: null,
519 error: null,
520 progress: [],
521 };
522 }
523
524 /**
525 * Load a local model by its ID and server type.

Callers 1

ModelLocationIndicatorFunction · 0.80

Calls 3

isTauriFunction · 0.90
getStateMethod · 0.65
getInstanceMethod · 0.45

Tested by

no test coverage detected