(ctx context.Context, keyword string)
| 99 | } |
| 100 | |
| 101 | func (i *imlLocalModel) Search(ctx context.Context, keyword string) ([]*ai_local_dto.LocalModelItem, error) { |
| 102 | list, err := i.localModelService.Search(ctx, keyword, nil, "update_at desc") |
| 103 | if err != nil { |
| 104 | return nil, err |
| 105 | } |
| 106 | apiCountMap, err := i.aiAPIService.CountMapByModel(ctx, "", map[string]interface{}{ |
| 107 | "type": 1, |
| 108 | }) |
| 109 | if err != nil { |
| 110 | return nil, err |
| 111 | } |
| 112 | |
| 113 | return utils.SliceToSlice(list, func(s *ai_local.LocalModel) *ai_local_dto.LocalModelItem { |
| 114 | count := apiCountMap[s.Id] |
| 115 | return &ai_local_dto.LocalModelItem{ |
| 116 | Id: s.Id, |
| 117 | Name: s.Name, |
| 118 | State: ai_local_dto.FromLocalModelState(s.State), |
| 119 | APICount: count, |
| 120 | CanDelete: count < 1 && s.State != ai_local_dto.LocalModelStateDeploying.Int(), |
| 121 | UpdateTime: auto.TimeLabel(s.UpdateAt), |
| 122 | Provider: ai_provider_local.ProviderLocal, |
| 123 | } |
| 124 | }), nil |
| 125 | } |
| 126 | |
| 127 | func (i *imlLocalModel) ListCanInstall(ctx context.Context, keyword string) ([]*ai_local_dto.LocalModelPackageItem, error) { |
| 128 |
nothing calls this directly
no test coverage detected