(ctx context.Context)
| 309 | } |
| 310 | |
| 311 | func (i *imlProviderModule) SimpleProviders(ctx context.Context) ([]*ai_dto.SimpleProviderItem, error) { |
| 312 | list, err := i.providerService.List(ctx) |
| 313 | if err != nil { |
| 314 | return nil, err |
| 315 | } |
| 316 | providers := model_runtime.Providers() |
| 317 | |
| 318 | providerMap := utils.SliceToMap(list, func(e *ai.Provider) string { |
| 319 | return e.Id |
| 320 | }) |
| 321 | |
| 322 | items := make([]*ai_dto.SimpleProviderItem, 0, len(providers)) |
| 323 | for _, v := range providers { |
| 324 | item := &ai_dto.SimpleProviderItem{ |
| 325 | Id: v.ID(), |
| 326 | Name: v.Name(), |
| 327 | Logo: v.Logo(), |
| 328 | DefaultConfig: v.DefaultConfig(), |
| 329 | Status: ai_dto.ProviderDisabled, |
| 330 | } |
| 331 | if info, has := providerMap[v.ID()]; has { |
| 332 | item.Configured = true |
| 333 | item.Status = ai_dto.ToProviderStatus(info.Status) |
| 334 | } |
| 335 | items = append(items, item) |
| 336 | } |
| 337 | |
| 338 | return items, nil |
| 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) |
nothing calls this directly
no test coverage detected