(ctx context.Context, all bool)
| 339 | } |
| 340 | |
| 341 | func (i *imlProviderModule) SimpleConfiguredProviders(ctx context.Context, all bool) ([]*ai_dto.SimpleProviderItem, *ai_dto.BackupProvider, error) { |
| 342 | list, err := i.providerService.List(ctx) |
| 343 | if err != nil { |
| 344 | return nil, nil, err |
| 345 | } |
| 346 | |
| 347 | items := make([]*ai_dto.SimpleProviderItem, 0, len(list)) |
| 348 | |
| 349 | healthProvider := make(map[string]struct{}) |
| 350 | if all { |
| 351 | healthProvider[ai_provider_local.ProviderLocal] = struct{}{} |
| 352 | items = append(items, &ai_dto.SimpleProviderItem{ |
| 353 | Id: ai_provider_local.ProviderLocal, |
| 354 | Name: ai_provider_local.ProviderLocal, |
| 355 | Logo: ai_provider_local.LocalSvg, |
| 356 | Configured: true, |
| 357 | DefaultConfig: "", |
| 358 | Status: ai_dto.ProviderEnabled, |
| 359 | Type: "local", |
| 360 | }) |
| 361 | } |
| 362 | |
| 363 | var backup *ai_dto.BackupProvider |
| 364 | for _, l := range list { |
| 365 | p, has := model_runtime.GetProvider(l.Id) |
| 366 | if !has { |
| 367 | continue |
| 368 | } |
| 369 | model, has := p.GetModel(l.DefaultLLM) |
| 370 | if !has { |
| 371 | model, has = p.DefaultModel(model_runtime.ModelTypeLLM) |
| 372 | if !has { |
| 373 | continue |
| 374 | } |
| 375 | } |
| 376 | item := &ai_dto.SimpleProviderItem{ |
| 377 | Id: l.Id, |
| 378 | Name: l.Name, |
| 379 | Logo: p.Logo(), |
| 380 | DefaultConfig: p.DefaultConfig(), |
| 381 | Status: ai_dto.ToProviderStatus(l.Status), |
| 382 | Configured: true, |
| 383 | Model: &ai_dto.BasicInfo{ |
| 384 | Id: model.ID(), |
| 385 | Name: model.ID(), |
| 386 | }, |
| 387 | } |
| 388 | if item.Status == ai_dto.ProviderEnabled { |
| 389 | healthProvider[l.Id] = struct{}{} |
| 390 | } |
| 391 | items = append(items, item) |
| 392 | } |
| 393 | |
| 394 | aiBalanceItems, err := i.aiBalanceService.Search(ctx, "", nil, "priority asc") |
| 395 | if err != nil { |
| 396 | return nil, nil, err |
| 397 | } |
| 398 | for _, item := range aiBalanceItems { |
nothing calls this directly
no test coverage detected