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

Method getAiProviders

module/ai/iml.go:705–742  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

703}
704
705func (i *imlProviderModule) getAiProviders(ctx context.Context) ([]*gateway.DynamicRelease, error) {
706 list, err := i.providerService.List(ctx)
707 if err != nil {
708 return nil, err
709 }
710
711 providers := make([]*gateway.DynamicRelease, 0, len(list))
712 for _, l := range list {
713 // 获取当前供应商所有Key信息
714
715 driver, has := model_runtime.GetProvider(l.Id)
716 if !has {
717 return nil, fmt.Errorf("provider not found: %s", l.Id)
718 }
719 model, has := driver.GetModel(l.DefaultLLM)
720 if !has {
721 continue
722 //return nil, fmt.Errorf("model not found: %s", l.DefaultLLM)
723 }
724 cfg := make(map[string]interface{})
725 cfg["provider"] = l.Id
726 cfg["model"] = l.DefaultLLM
727 cfg["model_config"] = model.DefaultConfig()
728 providers = append(providers, &gateway.DynamicRelease{
729 BasicItem: &gateway.BasicItem{
730 ID: l.Id,
731 Description: l.Name,
732 Resource: "ai-provider",
733 Version: l.UpdateAt.Format("20060102150405"),
734 MatchLabels: map[string]string{
735 "module": "ai-provider",
736 },
737 },
738 Attr: cfg,
739 })
740 }
741 return providers, nil
742}
743
744func (i *imlProviderModule) initGateway(ctx context.Context, clusterId string, clientDriver gateway.IClientDriver) error {
745 providers, err := i.getAiProviders(ctx)

Callers 1

initGatewayMethod · 0.95

Calls 3

ListMethod · 0.65
GetModelMethod · 0.65
DefaultConfigMethod · 0.65

Tested by

no test coverage detected