mirror of
https://github.com/ollama/ollama.git
synced 2025-12-08 01:02:23 +01:00
consistent error handling for pull and generate
This commit is contained in:
20
api/types.go
20
api/types.go
@@ -1,24 +1,5 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Error struct {
|
||||
Code int32 `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func (e Error) Error() string {
|
||||
if e.Message == "" {
|
||||
return fmt.Sprintf("%d %v", e.Code, strings.ToLower(http.StatusText(int(e.Code))))
|
||||
}
|
||||
|
||||
return e.Message
|
||||
}
|
||||
|
||||
type PullRequest struct {
|
||||
Model string `json:"model"`
|
||||
}
|
||||
@@ -27,7 +8,6 @@ type PullProgress struct {
|
||||
Total int64 `json:"total"`
|
||||
Completed int64 `json:"completed"`
|
||||
Percent float64 `json:"percent"`
|
||||
Error Error `json:"error"`
|
||||
}
|
||||
|
||||
type GenerateRequest struct {
|
||||
|
||||
Reference in New Issue
Block a user