-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.go
67 lines (56 loc) · 1.71 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package openaiclient
import "fmt"
// ListModelRequest ...
type ListModelRequest struct{}
// ListModelResponse ...
type ListModelResponse struct {
Data []RetrieveModelResponse `json:"data"`
Object string `json:"object"`
}
// RetrieveModelRequest ...
type RetrieveModelRequest struct {
}
// RetrieveModelResponse ...
type RetrieveModelResponse struct {
ID string `json:"id"`
Object string `json:"object"`
OwnedBy string `json:"owned_by"`
Permission []struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
AllowCreateEngine bool `json:"allow_create_engine"`
AllowSampling bool `json:"allow_sampling"`
AllowLogprobs bool `json:"allow_logprobs"`
ALlowSearchIndices bool `json:"allow_search_indices"`
AllowView bool `json:"allow_view"`
AllowFineTuning bool `json:"allow_fine_tuning"`
Organization string `json:"organization"`
// Group string `json:"group"`
IsBlocking bool `json:"is_blocking"`
} `json:"permission"`
Root string `json:"root"`
// Parent string `json:"parent"`
}
func (c *client) ListModels() (*ListModelResponse, error) {
resp, err := c.get("/models", nil)
if err != nil {
return nil, err
}
var response ListModelResponse
if err := resp.UnmarshalJSON(&response); err != nil {
return nil, err
}
return &response, nil
}
func (c *client) RetrieveModel(model string) (*RetrieveModelResponse, error) {
resp, err := c.get(fmt.Sprintf("/models/%s", model), nil)
if err != nil {
return nil, err
}
var response RetrieveModelResponse
if err := resp.UnmarshalJSON(&response); err != nil {
return nil, err
}
return &response, nil
}