* Fetch models from all sources (remote servers + refresh local cache)
()
| 273 | * Fetch models from all sources (remote servers + refresh local cache) |
| 274 | */ |
| 275 | public async fetchModels(): Promise<ModelsResponse> { |
| 276 | try { |
| 277 | const allModels: Model[] = []; |
| 278 | |
| 279 | // Fetch from all inference addresses |
| 280 | for (const address of this.inferenceAddresses) { |
| 281 | const models = await this.fetchFromAddress(address); |
| 282 | allModels.push(...models); |
| 283 | } |
| 284 | |
| 285 | // Update remote models state |
| 286 | this.remoteModels = allModels; |
| 287 | |
| 288 | // Refresh local model caches |
| 289 | // llama.cpp models (Tauri only) |
| 290 | if (isTauri()) { |
| 291 | await NativeLlmManager.getInstance().refreshGgufCache(); |
| 292 | } |
| 293 | // Note: GemmaModelManager doesn't have a refresh - it reads from localStorage synchronously |
| 294 | |
| 295 | this.notifyListeners(); |
| 296 | return this.listModels(); |
| 297 | } catch (error) { |
| 298 | return { |
| 299 | models: [], |
| 300 | error: `Could not retrieve models: ${error instanceof Error ? error.message : String(error)}` |
| 301 | }; |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * Fetch models from a single address |
no test coverage detected