* Fetch models from a single address
(address: string)
| 292 | * Fetch models from a single address |
| 293 | */ |
| 294 | private async fetchFromAddress(address: string): Promise<Model[]> { |
| 295 | try { |
| 296 | const response = await platformFetch(`${address}/v1/models`, { |
| 297 | method: 'GET', |
| 298 | headers: { 'Content-Type': 'application/json' }, |
| 299 | }); |
| 300 | |
| 301 | if (!response.ok) { |
| 302 | return []; |
| 303 | } |
| 304 | |
| 305 | const data = await response.json(); |
| 306 | const modelData = data.data || []; |
| 307 | |
| 308 | if (!Array.isArray(modelData)) { |
| 309 | return []; |
| 310 | } |
| 311 | |
| 312 | return modelData.map((model: any) => ({ |
| 313 | name: model.id, |
| 314 | parameterSize: model.parameter_size, |
| 315 | multimodal: model.multimodal ?? false, |
| 316 | pro: model.pro ?? false, |
| 317 | server: address, |
| 318 | ownedBy: model.owned_by |
| 319 | })); |
| 320 | } catch (error) { |
| 321 | return []; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | // =========================================================================== |
| 326 | // Server Management |
no test coverage detected