mirror of
https://github.com/ollama/ollama.git
synced 2026-04-18 10:54:10 +02:00
When an ollama key is not registered with any account on ollama.com this is not obvious. In the current CLI an error message that the user is not authorized is displayed. This change brings back previous behavior to show the user their key and where they should add it. It protects against adding unexpected keys by checking that the key is available locally. A follow-up change should add structured errors from the API. This change just relies on a known error message.
22 lines
446 B
Go
22 lines
446 B
Go
// Package errtypes contains custom error types
|
|
package errtypes
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
UnknownOllamaKeyErrMsg = "unknown ollama key"
|
|
InvalidModelNameErrMsg = "invalid model name"
|
|
)
|
|
|
|
// TODO: This should have a structured response from the API
|
|
type UnknownOllamaKey struct {
|
|
Key string
|
|
}
|
|
|
|
func (e UnknownOllamaKey) Error() string {
|
|
return fmt.Sprintf("unauthorized: %s %q", UnknownOllamaKeyErrMsg, strings.TrimSpace(e.Key))
|
|
}
|