mirror of https://github.com/usememos/memos
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
474 B
Go
17 lines
474 B
Go
|
3 months ago
|
package ai
|
||
|
|
|
||
|
|
import "github.com/pkg/errors"
|
||
|
|
|
||
|
|
// FindProvider returns the provider with the given ID.
|
||
|
|
func FindProvider(providers []ProviderConfig, providerID string) (*ProviderConfig, error) {
|
||
|
|
if providerID == "" {
|
||
|
|
return nil, errors.Wrap(ErrProviderNotFound, "provider ID is required")
|
||
|
|
}
|
||
|
|
for _, provider := range providers {
|
||
|
|
if provider.ID == providerID {
|
||
|
|
return &provider, nil
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return nil, errors.Wrapf(ErrProviderNotFound, "provider ID %q", providerID)
|
||
|
|
}
|