(ctx context.Context, v string)
| 260 | } |
| 261 | |
| 262 | func (i *imlBalanceModule) getLocalBalances(ctx context.Context, v string) ([]*gateway.DynamicRelease, error) { |
| 263 | balances, err := i.balanceService.Search(ctx, "", map[string]interface{}{"provider": ai_provider_local.ProviderLocal}, "priority asc") |
| 264 | if err != nil { |
| 265 | return nil, err |
| 266 | } |
| 267 | if v == "" { |
| 268 | var has bool |
| 269 | v, has = i.settingService.Get(ctx, "system.ai_model.ollama_address") |
| 270 | if !has { |
| 271 | //return nil, fmt.Errorf("ollama address not found") |
| 272 | return nil, nil |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | releases := make([]*gateway.DynamicRelease, 0, len(balances)) |
| 277 | for _, item := range balances { |
| 278 | base := v |
| 279 | if item.Provider != ai_provider_local.ProviderLocal { |
| 280 | p, has := model_runtime.GetProvider(item.Provider) |
| 281 | if !has { |
| 282 | continue |
| 283 | } |
| 284 | base = fmt.Sprintf("%s://%s%s", p.URI().Scheme(), p.URI().Host(), p.URI().Path()) |
| 285 | } |
| 286 | releases = append(releases, newRelease(item, base)) |
| 287 | } |
| 288 | return releases, nil |
| 289 | } |
| 290 | |
| 291 | func (i *imlBalanceModule) getBalances(ctx context.Context) ([]*gateway.DynamicRelease, error) { |
| 292 | balances, err := i.balanceService.Search(ctx, "", nil, "priority asc") |
no test coverage detected