Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
tangwenru committed Aug 13, 2023
1 parent 08bb44f commit 5e2fd9a
Show file tree
Hide file tree
Showing 39 changed files with 71 additions and 96 deletions.
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Contributing Guidelines

## Overview
Thank you for your interest in contributing to the "Go OpenAI" project! By following this guideline, we hope to ensure that your contributions are made smoothly and efficiently. The Go OpenAI project is licensed under the [Apache 2.0 License](https://github.com/sashabaranov/go-openai/blob/master/LICENSE), and we welcome contributions through GitHub pull requests.
Thank you for your interest in contributing to the "Go OpenAI" project! By following this guideline, we hope to ensure that your contributions are made smoothly and efficiently. The Go OpenAI project is licensed under the [Apache 2.0 License](https://github.com/tangwenru/go-openai/blob/master/LICENSE), and we welcome contributions through GitHub pull requests.

## Reporting Bugs
If you discover a bug, first check the [GitHub Issues page](https://github.com/sashabaranov/go-openai/issues) to see if the issue has already been reported. If you're reporting a new issue, please use the "Bug report" template and provide detailed information about the problem, including steps to reproduce it.
If you discover a bug, first check the [GitHub Issues page](https://github.com/tangwenru/go-openai/issues) to see if the issue has already been reported. If you're reporting a new issue, please use the "Bug report" template and provide detailed information about the problem, including steps to reproduce it.

## Suggesting Features
If you want to suggest a new feature or improvement, first check the [GitHub Issues page](https://github.com/sashabaranov/go-openai/issues) to ensure a similar suggestion hasn't already been made. Use the "Feature request" template to provide a detailed description of your suggestion.
If you want to suggest a new feature or improvement, first check the [GitHub Issues page](https://github.com/tangwenru/go-openai/issues) to ensure a similar suggestion hasn't already been made. Use the "Feature request" template to provide a detailed description of your suggestion.

## Reporting Vulnerabilities
If you identify a security concern, please use the "Report a security vulnerability" template on the [GitHub Issues page](https://github.com/sashabaranov/go-openai/issues) to share the details. This report will only be viewable to repository maintainers. You will be credited if the advisory is published.
If you identify a security concern, please use the "Report a security vulnerability" template on the [GitHub Issues page](https://github.com/tangwenru/go-openai/issues) to share the details. This report will only be viewable to repository maintainers. You will be credited if the advisory is published.

## Questions for Users
If you have questions, please utilize [StackOverflow](https://stackoverflow.com/) or the [GitHub Discussions page](https://github.com/sashabaranov/go-openai/discussions).
If you have questions, please utilize [StackOverflow](https://stackoverflow.com/) or the [GitHub Discussions page](https://github.com/tangwenru/go-openai/discussions).

## Contributing Code
There might already be a similar pull requests submitted! Please search for [pull requests](https://github.com/sashabaranov/go-openai/pulls) before creating one.
There might already be a similar pull requests submitted! Please search for [pull requests](https://github.com/tangwenru/go-openai/pulls) before creating one.

### Requirements for Merging a Pull Request

Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Go OpenAI
[![Go Reference](https://pkg.go.dev/badge/github.com/sashabaranov/go-openai.svg)](https://pkg.go.dev/github.com/sashabaranov/go-openai)
[![Go Report Card](https://goreportcard.com/badge/github.com/sashabaranov/go-openai)](https://goreportcard.com/report/github.com/sashabaranov/go-openai)
[![Go Reference](https://pkg.go.dev/badge/github.com/tangwenru/go-openai.svg)](https://pkg.go.dev/github.com/tangwenru/go-openai)
[![Go Report Card](https://goreportcard.com/badge/github.com/tangwenru/go-openai)](https://goreportcard.com/report/github.com/tangwenru/go-openai)
[![codecov](https://codecov.io/gh/sashabaranov/go-openai/branch/master/graph/badge.svg?token=bCbIfHLIsW)](https://codecov.io/gh/sashabaranov/go-openai)

This library provides unofficial Go clients for [OpenAI API](https://platform.openai.com/). We support:
Expand All @@ -13,7 +13,7 @@ This library provides unofficial Go clients for [OpenAI API](https://platform.op
## Installation

```
go get github.com/sashabaranov/go-openai
go get github.com/tangwenru/go-openai
```
Currently, go-openai requires Go version 1.18 or greater.

Expand All @@ -28,7 +28,7 @@ package main
import (
"context"
"fmt"
openai "github.com/sashabaranov/go-openai"
openai "github.com/tangwenru/go-openai"
)

func main() {
Expand Down Expand Up @@ -80,7 +80,7 @@ import (
"errors"
"fmt"
"io"
openai "github.com/sashabaranov/go-openai"
openai "github.com/tangwenru/go-openai"
)

func main() {
Expand Down Expand Up @@ -133,7 +133,7 @@ package main
import (
"context"
"fmt"
openai "github.com/sashabaranov/go-openai"
openai "github.com/tangwenru/go-openai"
)

func main() {
Expand Down Expand Up @@ -166,7 +166,7 @@ import (
"context"
"fmt"
"io"
openai "github.com/sashabaranov/go-openai"
openai "github.com/tangwenru/go-openai"
)

func main() {
Expand Down Expand Up @@ -215,7 +215,7 @@ import (
"context"
"fmt"

openai "github.com/sashabaranov/go-openai"
openai "github.com/tangwenru/go-openai"
)

func main() {
Expand Down Expand Up @@ -247,7 +247,7 @@ import (
"fmt"
"os"

openai "github.com/sashabaranov/go-openai"
openai "github.com/tangwenru/go-openai"
)

func main() {
Expand Down Expand Up @@ -288,7 +288,7 @@ import (
"context"
"encoding/base64"
"fmt"
openai "github.com/sashabaranov/go-openai"
openai "github.com/tangwenru/go-openai"
"image/png"
"os"
)
Expand Down Expand Up @@ -376,7 +376,7 @@ config.HTTPClient = &http.Client{
c := openai.NewClientWithConfig(config)
```

See also: https://pkg.go.dev/github.com/sashabaranov/go-openai#ClientConfig
See also: https://pkg.go.dev/github.com/tangwenru/go-openai#ClientConfig
</details>

<details>
Expand All @@ -392,7 +392,7 @@ import (
"os"
"strings"

"github.com/sashabaranov/go-openai"
"github.com/tangwenru/go-openai"
)

func main() {
Expand Down Expand Up @@ -446,7 +446,7 @@ import (
"context"
"fmt"

openai "github.com/sashabaranov/go-openai"
openai "github.com/tangwenru/go-openai"
)

func main() {
Expand Down Expand Up @@ -493,7 +493,7 @@ import (
"context"
"fmt"

openai "github.com/sashabaranov/go-openai"
openai "github.com/tangwenru/go-openai"
)

func main() {
Expand Down Expand Up @@ -624,7 +624,7 @@ package main
import (
"context"
"fmt"
"github.com/sashabaranov/go-openai"
"github.com/tangwenru/go-openai"
)

func main() {
Expand Down Expand Up @@ -702,7 +702,7 @@ Due to the factors mentioned above, different answers may be returned even for t
By adopting these strategies, you can expect more consistent results.

**Related Issues:**
[omitempty option of request struct will generate incorrect request when parameter is 0.](https://github.com/sashabaranov/go-openai/issues/9)
[omitempty option of request struct will generate incorrect request when parameter is 0.](https://github.com/tangwenru/go-openai/issues/9)

### Does Go OpenAI provide a method to count tokens?

Expand All @@ -713,15 +713,15 @@ For counting tokens, you might find the following links helpful:
- [How to count tokens with tiktoken](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb)

**Related Issues:**
[Is it possible to join the implementation of GPT3 Tokenizer](https://github.com/sashabaranov/go-openai/issues/62)
[Is it possible to join the implementation of GPT3 Tokenizer](https://github.com/tangwenru/go-openai/issues/62)

## Contributing

By following [Contributing Guidelines](https://github.com/sashabaranov/go-openai/blob/master/CONTRIBUTING.md), we hope to ensure that your contributions are made smoothly and efficiently.
By following [Contributing Guidelines](https://github.com/tangwenru/go-openai/blob/master/CONTRIBUTING.md), we hope to ensure that your contributions are made smoothly and efficiently.

## Thank you

We want to take a moment to express our deepest gratitude to the [contributors](https://github.com/sashabaranov/go-openai/graphs/contributors) and sponsors of this project:
We want to take a moment to express our deepest gratitude to the [contributors](https://github.com/tangwenru/go-openai/graphs/contributors) and sponsors of this project:
- [Carson Kahn](https://carsonkahn.com) of [Spindle AI](https://spindleai.com)

To all of you: thank you. You've helped us achieve more than we ever imagined possible. Can't wait to see where we go next, together!
7 changes: 6 additions & 1 deletion EDIT.md → _EDIT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# 修改记录

#
文件 `config.go`

```go
Expand All @@ -10,4 +12,7 @@ func NewClient(authToken string, baseURL string) *Client {
+ }
return NewClientWithConfig(config)
}
```
```

#
`github.com/sashabaranov/go-openai` 改为 `github.com/tangwenru/go-openai`
6 changes: 3 additions & 3 deletions api_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"os"
"testing"

. "github.com/sashabaranov/go-openai"
"github.com/sashabaranov/go-openai/internal/test/checks"
"github.com/sashabaranov/go-openai/jsonschema"
. "github.com/tangwenru/go-openai"
"github.com/tangwenru/go-openai/internal/test/checks"
"github.com/tangwenru/go-openai/jsonschema"
)

func TestAPI(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"os"

utils "github.com/sashabaranov/go-openai/internal"
utils "github.com/tangwenru/go-openai/internal"
)

// Whisper Defines the models provided by OpenAI to use when processing audio with OpenAI.
Expand Down
5 changes: 2 additions & 3 deletions audio_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import (
"strings"
"testing"

. "github.com/sashabaranov/go-openai"
"github.com/sashabaranov/go-openai/internal/test"
"github.com/sashabaranov/go-openai/internal/test/checks"
"github.com/tangwenru/go-openai/internal/test"
"github.com/tangwenru/go-openai/internal/test/checks"
)

// TestAudio Tests the transcription and translation endpoints of the API using the mocked server.
Expand Down
4 changes: 2 additions & 2 deletions audio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"path/filepath"
"testing"

"github.com/sashabaranov/go-openai/internal/test"
"github.com/sashabaranov/go-openai/internal/test/checks"
"github.com/tangwenru/go-openai/internal/test"
"github.com/tangwenru/go-openai/internal/test/checks"
)

func TestAudioWithFailingFormBuilder(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions chat_stream_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package openai_test

import (
. "github.com/sashabaranov/go-openai"
"github.com/sashabaranov/go-openai/internal/test/checks"
"github.com/tangwenru/go-openai/internal/test/checks"

"context"
"encoding/json"
Expand Down
5 changes: 2 additions & 3 deletions chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import (
"testing"
"time"

. "github.com/sashabaranov/go-openai"
"github.com/sashabaranov/go-openai/internal/test/checks"
"github.com/sashabaranov/go-openai/jsonschema"
"github.com/tangwenru/go-openai/internal/test/checks"
"github.com/tangwenru/go-openai/jsonschema"
)

func TestChatCompletionsWrongModel(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"net/http"
"strings"

utils "github.com/sashabaranov/go-openai/internal"
utils "github.com/tangwenru/go-openai/internal"
)

// Client is OpenAI GPT-3 API client.
Expand Down
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"net/http"
"testing"

"github.com/sashabaranov/go-openai/internal/test"
"github.com/tangwenru/go-openai/internal/test"
)

var errTestRequestBuilderFailed = errors.New("test request builder failed")
Expand Down
3 changes: 1 addition & 2 deletions completion_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package openai_test

import (
. "github.com/sashabaranov/go-openai"
"github.com/sashabaranov/go-openai/internal/test/checks"
"github.com/tangwenru/go-openai/internal/test/checks"

"context"
"encoding/json"
Expand Down
2 changes: 0 additions & 2 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package openai_test

import (
"testing"

. "github.com/sashabaranov/go-openai"
)

func TestGetAzureDeploymentByModel(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions edits_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package openai_test

import (
. "github.com/sashabaranov/go-openai"
"github.com/sashabaranov/go-openai/internal/test/checks"
"github.com/tangwenru/go-openai/internal/test/checks"

"context"
"encoding/json"
Expand Down
3 changes: 1 addition & 2 deletions embeddings_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package openai_test

import (
. "github.com/sashabaranov/go-openai"
"github.com/sashabaranov/go-openai/internal/test/checks"
"github.com/tangwenru/go-openai/internal/test/checks"

"bytes"
"context"
Expand Down
3 changes: 1 addition & 2 deletions engines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"net/http"
"testing"

. "github.com/sashabaranov/go-openai"
"github.com/sashabaranov/go-openai/internal/test/checks"
"github.com/tangwenru/go-openai/internal/test/checks"
)

// TestGetEngine Tests the retrieve engine endpoint of the API using the mocked server.
Expand Down
4 changes: 2 additions & 2 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (e *APIError) UnmarshalJSON(data []byte) (err error) {
err = json.Unmarshal(rawMap["message"], &e.Message)
if err != nil {
// If the parameter field of a function call is invalid as a JSON schema
// refs: https://github.com/sashabaranov/go-openai/issues/381
// refs: https://github.com/tangwenru/go-openai/issues/381
var messages []string
err = json.Unmarshal(rawMap["message"], &messages)
if err != nil {
Expand All @@ -61,7 +61,7 @@ func (e *APIError) UnmarshalJSON(data []byte) (err error) {
}

// optional fields for azure openai
// refs: https://github.com/sashabaranov/go-openai/issues/343
// refs: https://github.com/tangwenru/go-openai/issues/343
if _, ok := rawMap["type"]; ok {
err = json.Unmarshal(rawMap["type"], &e.Type)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"net/http"
"reflect"
"testing"

. "github.com/sashabaranov/go-openai"
)

func TestAPIErrorUnmarshalJSON(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"net/http"
"net/url"
"os"

"github.com/sashabaranov/go-openai"
)

func Example() {
Expand Down
2 changes: 0 additions & 2 deletions examples/chatbot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"context"
"fmt"
"os"

"github.com/sashabaranov/go-openai"
)

func main() {
Expand Down
2 changes: 0 additions & 2 deletions examples/completion/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"fmt"
"os"

"github.com/sashabaranov/go-openai"
)

func main() {
Expand Down
2 changes: 0 additions & 2 deletions examples/images/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"fmt"
"os"

"github.com/sashabaranov/go-openai"
)

func main() {
Expand Down
Loading

0 comments on commit 5e2fd9a

Please sign in to comment.