getProvider returns a specific provider by ID. A provider the Store's knownProvider predicate rejects (a user-defined custom provider) is looked up without ever fetching the catalog from the network, so a self-contained custom-provider config keeps working when models.dev is unreachable.
(ctx context.Context, providerID string)
| 198 | // up without ever fetching the catalog from the network, so a self-contained |
| 199 | // custom-provider config keeps working when models.dev is unreachable. |
| 200 | func (s *Store) getProvider(ctx context.Context, providerID string) (*Provider, error) { |
| 201 | allowFetch := s.knownProvider == nil || s.knownProvider(providerID) |
| 202 | |
| 203 | db, err := s.getDatabase(ctx, allowFetch) |
| 204 | if err != nil { |
| 205 | return nil, err |
| 206 | } |
| 207 | |
| 208 | provider, exists := db.Providers[providerID] |
| 209 | if !exists { |
| 210 | return nil, fmt.Errorf("provider %q not found", providerID) |
| 211 | } |
| 212 | |
| 213 | return &provider, nil |
| 214 | } |
| 215 | |
| 216 | // GetModel returns a specific model by ID. The ID must carry both a |
| 217 | // provider and a model component; pass the result of [NewID], [ParseID], |
no test coverage detected