types.go 732 Bytes
Newer Older
Jeffrey Morgan's avatar
Jeffrey Morgan committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
}

Bruce MacDonald's avatar
Bruce MacDonald committed
21
22
23
24
25
26
27
28
type PullRequest struct {
	Model string `json:"model"`
}

type PullResponse struct {
	Response string `json:"response"`
}

Jeffrey Morgan's avatar
Jeffrey Morgan committed
29
30
31
32
33
34
35
36
type GenerateRequest struct {
	Model  string `json:"model"`
	Prompt string `json:"prompt"`
}

type GenerateResponse struct {
	Response string `json:"response"`
}
Michael Yang's avatar
Michael Yang committed
37
38
39
40
41
42
43
44

type TokenResponse struct {
	Choices []TokenResponseChoice `json:"choices"`
}

type TokenResponseChoice struct {
	Text string `json:"text"`
}