MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / getBalances

Method getBalances

module/ai-balance/iml.go:291–318  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

289}
290
291func (i *imlBalanceModule) getBalances(ctx context.Context) ([]*gateway.DynamicRelease, error) {
292 balances, err := i.balanceService.Search(ctx, "", nil, "priority asc")
293 if err != nil {
294 return nil, err
295 }
296 v, has := i.settingService.Get(ctx, "system.ai_model.ollama_address")
297 if !has {
298 //return nil, fmt.Errorf("ollama address not found")
299 return nil, nil
300 }
301 releases := make([]*gateway.DynamicRelease, 0, len(balances))
302 for _, item := range balances {
303 base := v
304 if item.Provider != ai_provider_local.ProviderLocal {
305 p, has := model_runtime.GetProvider(item.Provider)
306 if !has {
307 continue
308 }
309 base = fmt.Sprintf("%s://%s%s", p.URI().Scheme(), p.URI().Host(), p.URI().Path())
310 } else {
311 if v == "" {
312 continue
313 }
314 }
315 releases = append(releases, newRelease(item, base))
316 }
317 return releases, nil
318}
319
320func (i *imlBalanceModule) initGateway(ctx context.Context, clusterId string, clientDriver gateway.IClientDriver) error {
321 releases, err := i.getBalances(ctx)

Callers 1

initGatewayMethod · 0.95

Calls 7

newReleaseFunction · 0.85
SearchMethod · 0.65
GetMethod · 0.65
SchemeMethod · 0.65
URIMethod · 0.65
HostMethod · 0.65
PathMethod · 0.65

Tested by

no test coverage detected