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

Method getLocalModelState

app/src/utils/ModelManager.ts:508–552  ·  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

506 * Returns the current loading/loaded state for the specified engine.
507 */
508 public getLocalModelState(server: string): LocalModelState {
509 if (server === ModelManager.BROWSER_LOCAL) {
510 const gemmaState = GemmaModelManager.getInstance().getState();
511 return {
512 status: gemmaState.status === 'unloaded' ? 'unloaded'
513 : gemmaState.status === 'loading' ? 'loading'
514 : gemmaState.status === 'loaded' ? 'loaded'
515 : 'error',
516 modelId: gemmaState.modelId,
517 error: gemmaState.error,
518 progress: gemmaState.progress.map(p => ({
519 file: p.file,
520 progress: p.progress,
521 loaded: p.loaded,
522 total: p.total,
523 done: p.status === 'done',
524 })),
525 engineInfo: gemmaState.loadSettings ? {
526 type: 'transformers.js',
527 device: gemmaState.loadSettings.device,
528 dtype: gemmaState.loadSettings.dtype,
529 enableThinking: gemmaState.loadSettings.enableThinking ?? false,
530 } : { type: 'transformers.js' },
531 };
532 }
533
534 if (server === ModelManager.LLAMA_CPP_LOCAL && isTauri()) {
535 const nativeState = NativeLlmManager.getInstance().getState();
536 return {
537 status: nativeState.status,
538 modelId: nativeState.modelId,
539 error: nativeState.error,
540 progress: [], // llama.cpp doesn't have file-level progress
541 engineInfo: { type: 'llama.cpp' },
542 };
543 }
544
545 // Default state for unknown server
546 return {
547 status: 'unloaded',
548 modelId: null,
549 error: null,
550 progress: [],
551 };
552 }
553
554 /**
555 * 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