-
Notifications
You must be signed in to change notification settings - Fork 4
/
engines.go
54 lines (45 loc) · 1.33 KB
/
engines.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
package openai
import (
"context"
"encoding/json"
"path"
"github.com/fabiustech/openai/routes"
)
// Engine contains all relevant fields for requests to the engines endpoint.
type Engine struct {
ID string `json:"id"`
Object string `json:"object"`
Owner string `json:"owner"`
Ready bool `json:"ready"`
}
// ListEngines lists the currently available engines, and provides basic
// information about each option such as the owner and availability.
//
// Deprecated: Please use their replacement, Models, instead.
// https://beta.openai.com/docs/api-reference/models
func (c *Client) ListEngines(ctx context.Context) (*List[*Engine], error) {
var b, err = c.get(ctx, routes.Engines)
if err != nil {
return nil, err
}
var el = &List[*Engine]{}
if err = json.Unmarshal(b, el); err != nil {
return nil, err
}
return el, nil
}
// GetEngine retrieves a model instance, providing basic information about it such as the owner and availability.
//
// Deprecated: Please use their replacement, Models, instead.
// https://beta.openai.com/docs/api-reference/models
func (c *Client) GetEngine(ctx context.Context, id string) (*Engine, error) {
var b, err = c.get(ctx, path.Join(routes.Engines, id))
if err != nil {
return nil, err
}
var e = &Engine{}
if err = json.Unmarshal(b, e); err != nil {
return nil, err
}
return e, nil
}