ollama/api/types.go

45 lines
732 B
Go
Raw Normal View History

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
}
2023-07-06 16:24:49 +00:00
type PullRequest struct {
Model string `json:"model"`
}
type PullResponse struct {
Response string `json:"response"`
}
type GenerateRequest struct {
Model string `json:"model"`
Prompt string `json:"prompt"`
}
type GenerateResponse struct {
Response string `json:"response"`
}
2023-07-06 17:40:11 +00:00
type TokenResponse struct {
Choices []TokenResponseChoice `json:"choices"`
}
type TokenResponseChoice struct {
Text string `json:"text"`
}