(address: string)
| 473 | } |
| 474 | |
| 475 | public async checkServer(address: string): Promise<{ status: 'online' | 'offline'; error?: string }> { |
| 476 | try { |
| 477 | const response = await platformFetch(`${address}/v1/models`, { |
| 478 | method: 'GET', |
| 479 | headers: { 'Content-Type': 'application/json' }, |
| 480 | }); |
| 481 | |
| 482 | if (response.ok) { |
| 483 | return { status: 'online' }; |
| 484 | } |
| 485 | |
| 486 | return { |
| 487 | status: 'offline', |
| 488 | error: `Server responded with status ${response.status}` |
| 489 | }; |
| 490 | } catch (error) { |
| 491 | const detail = error instanceof Error ? `${error.name}: ${error.message}` : String(error); |
| 492 | console.error(`[ModelManager] checkServer(${address}) failed:`, error); |
| 493 | return { |
| 494 | status: 'offline', |
| 495 | error: `Could not connect to server (${detail})${error instanceof TypeError ? '\nMaybe check CORS?' : ''}` |
| 496 | }; |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | // =========================================================================== |
| 501 | // Local Model Management (unified interface) |
no test coverage detected