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

Method LLMs

module/ai/iml.go:518–567  ·  view source on GitHub ↗
(ctx context.Context, driver string)

Source from the content-addressed store, hash-verified

516}
517
518func (i *imlProviderModule) LLMs(ctx context.Context, driver string) ([]*ai_dto.LLMItem, *ai_dto.ProviderItem, error) {
519 p, has := model_runtime.GetProvider(driver)
520 if !has {
521 return nil, nil, fmt.Errorf("ai provider not found")
522 }
523
524 llms, _ := p.ModelsByType(model_runtime.ModelTypeLLM)
525 modelApiCountMap, _ := i.aiAPIService.CountMapByModel(ctx, "", map[string]interface{}{"provider": driver})
526 items := make([]*ai_dto.LLMItem, 0, len(llms))
527 for _, v := range llms {
528 items = append(items, &ai_dto.LLMItem{
529 Id: v.ID(),
530 Name: v.Name(),
531 Logo: v.Logo(),
532 Config: v.DefaultConfig(),
533 AccessConfiguration: v.AccessConfiguration(),
534 ModelParameters: v.ModelParameters(),
535 Scopes: []string{
536 "chat",
537 },
538 Type: "chat",
539 IsSystem: v.Source() != "customize",
540 ApiCount: modelApiCountMap[v.ID()],
541 })
542 }
543 info, err := i.providerService.Get(ctx, driver)
544 if err != nil {
545 if !errors.Is(err, gorm.ErrRecordNotFound) {
546 return nil, nil, err
547 }
548 defaultLLMID := ""
549 defaultLLM, _ := p.DefaultModel(model_runtime.ModelTypeLLM)
550 if defaultLLM != nil {
551 defaultLLMID = defaultLLM.ID()
552 }
553 return items, &ai_dto.ProviderItem{
554 Id: p.ID(),
555 Name: p.Name(),
556 DefaultLLM: defaultLLMID,
557 Logo: p.Logo(),
558 }, nil
559 }
560
561 return items, &ai_dto.ProviderItem{
562 Id: info.Id,
563 Name: info.Name,
564 DefaultLLM: info.DefaultLLM,
565 Logo: p.Logo(),
566 }, nil
567}
568
569func (i *imlProviderModule) UpdateProviderConfig(ctx context.Context, id string, input *ai_dto.UpdateConfig) error {
570 p, has := model_runtime.GetProvider(id)

Callers

nothing calls this directly

Calls 11

ModelsByTypeMethod · 0.65
CountMapByModelMethod · 0.65
IDMethod · 0.65
NameMethod · 0.65
LogoMethod · 0.65
DefaultConfigMethod · 0.65
AccessConfigurationMethod · 0.65
ModelParametersMethod · 0.65
SourceMethod · 0.65
GetMethod · 0.65
DefaultModelMethod · 0.65

Tested by

no test coverage detected