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

Method ListCanInstall

module/ai-local/iml.go:127–163  ·  view source on GitHub ↗
(ctx context.Context, keyword string)

Source from the content-addressed store, hash-verified

125}
126
127func (i *imlLocalModel) ListCanInstall(ctx context.Context, keyword string) ([]*ai_local_dto.LocalModelPackageItem, error) {
128
129 if keyword == "" {
130 list, err := i.localModelPackageService.Search(ctx, keyword, nil)
131 if err != nil {
132 return nil, err
133 }
134 return utils.SliceToSlice(list, func(s *ai_local.LocalModelPackage) *ai_local_dto.LocalModelPackageItem {
135 return &ai_local_dto.LocalModelPackageItem{
136 Id: s.Id,
137 Name: s.Name,
138 Size: s.Size,
139 IsPopular: s.IsPopular,
140 }
141 }), nil
142 } else {
143 info, err := i.localModelPackageService.Get(ctx, keyword)
144 if err != nil {
145 return nil, err
146 }
147 result := make([]*ai_local_dto.LocalModelPackageItem, 0)
148
149 //for _, v := range list {
150 models := ai_provider_local.ModelsCanInstallById(info.Id)
151 for _, model := range models {
152 result = append(result, &ai_local_dto.LocalModelPackageItem{
153 Id: model.Id,
154 Name: model.Name,
155 Size: model.Size,
156 IsPopular: model.IsPopular,
157 })
158 }
159 //}
160 return result, nil
161 }
162
163}
164
165func (i *imlLocalModel) pullHook(fn ...func() error) func(msg ai_provider_local.PullMessage) error {
166 return func(msg ai_provider_local.PullMessage) error {

Callers

nothing calls this directly

Calls 2

SearchMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected