Skip to content

Commit

Permalink
chore: rename module chatgpt to openai
Browse files Browse the repository at this point in the history
  • Loading branch information
0x9ef committed Dec 29, 2022
1 parent 4a8d189 commit c204a59
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion completions.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2022 0x9ef. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package chatgpt
package openai

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion completions_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2022 0x9ef. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package chatgpt
package openai

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion edits.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2022 0x9ef. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package chatgpt
package openai

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion edits_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2022 0x9ef. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package chatgpt
package openai

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion error.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2022 0x9ef. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package chatgpt
package openai

import "encoding/json"

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/0x9ef/chatgpt-go
module github.com/0x9ef/openai-go

go 1.19

Expand Down
2 changes: 1 addition & 1 deletion models.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2022 0x9ef. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package chatgpt
package openai

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion models_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2022 0x9ef. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package chatgpt
package openai

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion chatgpt.go → openai.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2022 0x9ef. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package chatgpt
package openai

import (
"bytes"
Expand Down
34 changes: 17 additions & 17 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Golang OpenAI GPT-3 API Client
# Golang OpenAI API Client

An Golang native implementation to easily interacting with OpenAI API.

Expand All @@ -11,24 +11,24 @@ export OPENAPI_KEY=YOUR_KEY

To initialize engine, use this:
```go
e := chatgpt.New(os.Getenv("OPENAPI_KEY"))
e := openai.New(os.Getenv("OPENAPI_KEY"))
```

### Text completion example
Given a prompt, the model will return one or more predicted completions.

```go
e := chatgpt.New(os.Getenv("OPENAPI_KEY"))
r, err := e.Completion(context.Background(), &chatgpt.CompletionOptions{
e := openai.New(os.Getenv("OPENAPI_KEY"))
r, err := e.Completion(context.Background(), &openai.CompletionOptions{
// Choose model, you can see list of available models in models.go file
Model: chatgpt.ModelTextDavinci001,
Model: openai.ModelTextDavinci001,
// Text to completion
Prompt: []string{"Write a little bit of Wikipedia. What is that?"},
})
```

You will get the next output:
```
```json
{
"id": "cmpl-6SrcYDLCVT7xyHKVNuSLNuhRvwOJ1",
"object": "text_completion",
Expand Down Expand Up @@ -66,14 +66,14 @@ import (
"os"
"testing"

"github.com/0x9ef/chatgpt-go"
"github.com/0x9ef/openai-go"
)

func main() {
e := chatgpt.New(os.Getenv("OPENAPI_KEY"))
r, err := e.Completion(context.Background(), &chatgpt.CompletionOptions{
e := openai.New(os.Getenv("OPENAPI_KEY"))
r, err := e.Completion(context.Background(), &openai.CompletionOptions{
// Choose model, you can see list of available models in models.go file
Model: chatgpt.ModelTextDavinci001,
Model: openai.ModelTextDavinci001,
// Text to completion
Prompt: []string{"Write a little bit of Wikipedia. What is that?"}
})
Expand All @@ -93,7 +93,7 @@ func main() {
Lists the currently available models, and provides basic information about each one such as the owner and availability.

```go
e := chatgpt.New(os.Getenv("OPENAPI_KEY"))
e := openai.New(os.Getenv("OPENAPI_KEY"))
r, err := e.ListModels(context.Background())
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -126,15 +126,15 @@ You will get the next output:
},
...
]
}
}
```

To retrieve information about specified model instead of all models, you can do this:

```go
e := chatgpt.New(os.Getenv("OPENAPI_KEY"))
r, err := e.RetrieveModel(context.Background(), &chatgpt.RetrieveModelOptions{
ID: chatgpt.ModelDavinci,
e := openai.New(os.Getenv("OPENAPI_KEY"))
r, err := e.RetrieveModel(context.Background(), &openai.RetrieveModelOptions{
ID: openai.ModelDavinci,
})
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit c204a59

Please sign in to comment.