Skip to content

Commit f6e1b05

Browse files
committed
fix: make engine public
1 parent a1494ea commit f6e1b05

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

completions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type CompletionResponse struct {
4949
//
5050
// The default number of tokens to complete is 1024.
5151
// Docs: https://beta.openai.com/docs/api-reference/completions
52-
func (e *engine) Completion(ctx context.Context, opts *CompletionOptions) (*CompletionResponse, error) {
52+
func (e *Engine) Completion(ctx context.Context, opts *CompletionOptions) (*CompletionResponse, error) {
5353
if err := e.validate.StructCtx(ctx, opts); err != nil {
5454
return nil, err
5555
}

edits.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type EditResponse struct {
4242
// Edit given a prompt and an instruction, the model will return an edited version of the prompt.
4343
//
4444
// Docs: https://beta.openai.com/docs/api-reference/edits
45-
func (e *engine) Edit(ctx context.Context, opts *EditOptions) (*EditResponse, error) {
45+
func (e *Engine) Edit(ctx context.Context, opts *EditOptions) (*EditResponse, error) {
4646
if err := e.validate.StructCtx(ctx, opts); err != nil {
4747
return nil, err
4848
}

images.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type ImageCreateResponse struct {
5555
// ImageCreate given a prompt and/or an input image, the model will generate a new image.
5656
//
5757
// Docs: https://beta.openai.com/docs/api-reference/images/create
58-
func (e *engine) ImageCreate(ctx context.Context, opts *ImageCreateOptions) (*ImageCreateResponse, error) {
58+
func (e *Engine) ImageCreate(ctx context.Context, opts *ImageCreateOptions) (*ImageCreateResponse, error) {
5959
if err := e.validate.StructCtx(ctx, opts); err != nil {
6060
return nil, err
6161
}
@@ -116,7 +116,7 @@ type ImageEditResponse struct {
116116
// ImageEdit creates an edited or extended image given an original image and a prompt.
117117
//
118118
// Docs: https://beta.openai.com/docs/api-reference/images/create-edit
119-
func (e *engine) ImageEdit(ctx context.Context, opts *ImageEditOptions) (*ImageEditResponse, error) {
119+
func (e *Engine) ImageEdit(ctx context.Context, opts *ImageEditOptions) (*ImageEditResponse, error) {
120120
if err := e.validate.StructCtx(ctx, opts); err != nil {
121121
return nil, err
122122
}
@@ -178,7 +178,7 @@ type ImageVariationResponse struct {
178178
// ImageVariation creates a variation of a given image.
179179
//
180180
// Docs: https://beta.openai.com/docs/api-reference/images/create-variation
181-
func (e *engine) ImageVariation(ctx context.Context, opts *ImageVariationOptions) (*ImageCreateResponse, error) {
181+
func (e *Engine) ImageVariation(ctx context.Context, opts *ImageVariationOptions) (*ImageCreateResponse, error) {
182182
if err := e.validate.StructCtx(ctx, opts); err != nil {
183183
return nil, err
184184
}

models.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type ListModelsResponse struct {
3939
// each one such as the owner and availability.
4040
//
4141
// Docs: https://beta.openai.com/docs/api-reference/models/list
42-
func (e *engine) ListModels(ctx context.Context) (*ListModelsResponse, error) {
42+
func (e *Engine) ListModels(ctx context.Context) (*ListModelsResponse, error) {
4343
url := e.apiBaseURL + "/models"
4444
req, err := e.newReq(ctx, http.MethodGet, url, "", nil)
4545
if err != nil {
@@ -71,7 +71,7 @@ type RetrieveModelResponse struct {
7171
// about the model such as the owner and permissioning.
7272
//
7373
// Docs: https://beta.openai.com/docs/api-reference/models/retrieve
74-
func (e *engine) RetrieveModel(ctx context.Context, opts *RetrieveModelOptions) (*RetrieveModelResponse, error) {
74+
func (e *Engine) RetrieveModel(ctx context.Context, opts *RetrieveModelOptions) (*RetrieveModelResponse, error) {
7575
if err := e.validate.StructCtx(ctx, opts); err != nil {
7676
return nil, err
7777
}

openai.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/go-playground/validator/v10"
1515
)
1616

17-
type engine struct {
17+
type Engine struct {
1818
apiKey string
1919
apiBaseURL string
2020
organizationId string
@@ -28,8 +28,8 @@ const (
2828
)
2929

3030
// New is used to initialize engine.
31-
func New(apiKey string) *engine {
32-
e := &engine{
31+
func New(apiKey string) *Engine {
32+
e := &Engine{
3333
apiKey: apiKey,
3434
apiBaseURL: "https://api.openai.com/v1",
3535
client: &http.Client{},
@@ -42,16 +42,16 @@ func New(apiKey string) *engine {
4242
}
4343

4444
// SetApiKey is used to set API key to access OpenAI API.
45-
func (e *engine) SetApiKey(apiKey string) {
45+
func (e *Engine) SetApiKey(apiKey string) {
4646
e.apiKey = apiKey
4747
}
4848

4949
// SetOrganizationId is used to set organization ID if user belongs to multiple organizations.
50-
func (e *engine) SetOrganizationId(organizationId string) {
50+
func (e *Engine) SetOrganizationId(organizationId string) {
5151
e.organizationId = organizationId
5252
}
5353

54-
func (e *engine) newReq(ctx context.Context, method string, uri string, postType string, body io.Reader) (*http.Request, error) {
54+
func (e *Engine) newReq(ctx context.Context, method string, uri string, postType string, body io.Reader) (*http.Request, error) {
5555
if ctx == nil {
5656
ctx = context.Background() // prevent nil context error
5757
}
@@ -76,7 +76,7 @@ func (e *engine) newReq(ctx context.Context, method string, uri string, postType
7676
return req, err
7777
}
7878

79-
func (e *engine) doReq(req *http.Request) (*http.Response, error) {
79+
func (e *Engine) doReq(req *http.Request) (*http.Response, error) {
8080
e.n++ // increment number of requests
8181
resp, err := e.client.Do(req)
8282
if err != nil {

0 commit comments

Comments
 (0)