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