Skip to content

同步主仓库 #992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api_integration_test.go
Original file line number Diff line number Diff line change
@@ -10,9 +10,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/lantiancai/go-openai"
"github.com/lantiancai/go-openai/internal/test/checks"
"github.com/lantiancai/go-openai/jsonschema"
)

func TestAPI(t *testing.T) {
4 changes: 2 additions & 2 deletions assistant_test.go
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ package openai_test
import (
"context"

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

"encoding/json"
"fmt"
2 changes: 1 addition & 1 deletion audio.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (
"net/http"
"os"

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

// Whisper Defines the models provided by OpenAI to use when processing audio with OpenAI.
6 changes: 3 additions & 3 deletions audio_api_test.go
Original file line number Diff line number Diff line change
@@ -12,9 +12,9 @@ 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/lantiancai/go-openai"
"github.com/lantiancai/go-openai/internal/test"
"github.com/lantiancai/go-openai/internal/test/checks"
)

// TestAudio Tests the transcription and translation endpoints of the API using the mocked server.
6 changes: 3 additions & 3 deletions audio_test.go
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@ import (
"path/filepath"
"testing"

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

func TestAudioWithFailingFormBuilder(t *testing.T) {
4 changes: 2 additions & 2 deletions batch_test.go
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ import (
"reflect"
"testing"

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

func TestUploadBatchFile(t *testing.T) {
6 changes: 6 additions & 0 deletions chat_stream.go
Original file line number Diff line number Diff line change
@@ -37,12 +37,18 @@ type ChatCompletionTokenLogprobTopLogprob struct {
Logprob float64 `json:"logprob"`
}

type MessageData struct {
Role string `json:"role"`
Content string `json:"content"`
}
type ChatCompletionStreamChoice struct {
Index int `json:"index"`
Delta ChatCompletionStreamChoiceDelta `json:"delta"`
Logprobs *ChatCompletionStreamChoiceLogprobs `json:"logprobs,omitempty"`
FinishReason FinishReason `json:"finish_reason"`
ContentFilterResults ContentFilterResults `json:"content_filter_results,omitempty"`
// sb sentence
Message MessageData `json:"message,omitempty"`
}

type PromptFilterResult struct {
4 changes: 2 additions & 2 deletions chat_stream_test.go
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@ import (
"strconv"
"testing"

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

func TestChatCompletionsStreamWrongModel(t *testing.T) {
6 changes: 3 additions & 3 deletions chat_test.go
Original file line number Diff line number Diff line change
@@ -12,9 +12,9 @@ import (
"testing"
"time"

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

const (
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import (
"net/url"
"strings"

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

// Client is OpenAI GPT-3 API client.
4 changes: 2 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@ import (
"reflect"
"testing"

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

var errTestRequestBuilderFailed = errors.New("test request builder failed")
4 changes: 2 additions & 2 deletions completion_test.go
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@ import (
"testing"
"time"

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

func TestCompletionsWrongModel(t *testing.T) {
2 changes: 1 addition & 1 deletion config_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package openai_test
import (
"testing"

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

func TestGetAzureDeploymentByModel(t *testing.T) {
4 changes: 2 additions & 2 deletions edits_test.go
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ import (
"testing"
"time"

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

// TestEdits Tests the edits endpoint of the API using the mocked server.
4 changes: 2 additions & 2 deletions embeddings_test.go
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ import (
"reflect"
"testing"

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

func TestEmbedding(t *testing.T) {
4 changes: 2 additions & 2 deletions engines_test.go
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ import (
"net/http"
"testing"

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

// TestGetEngine Tests the retrieve engine endpoint of the API using the mocked server.
4 changes: 2 additions & 2 deletions error.go
Original file line number Diff line number Diff line change
@@ -54,7 +54,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/lantiancai/go-openai/issues/381
var messages []string
err = json.Unmarshal(rawMap["message"], &messages)
if err != nil {
@@ -64,7 +64,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/lantiancai/go-openai/issues/343
if _, ok := rawMap["type"]; ok {
err = json.Unmarshal(rawMap["type"], &e.Type)
if err != nil {
2 changes: 1 addition & 1 deletion error_test.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (
"reflect"
"testing"

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

func TestAPIErrorUnmarshalJSON(t *testing.T) {
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import (
"net/url"
"os"

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

func Example() {
2 changes: 1 addition & 1 deletion examples/chatbot/main.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (
"fmt"
"os"

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

func main() {
4 changes: 2 additions & 2 deletions examples/completion-with-tool/main.go
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ import (
"fmt"
"os"

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

func main() {
2 changes: 1 addition & 1 deletion examples/completion/main.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (
"fmt"
"os"

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

func main() {
2 changes: 1 addition & 1 deletion examples/images/main.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (
"fmt"
"os"

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

func main() {
2 changes: 1 addition & 1 deletion examples/voice-to-text/main.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (
"fmt"
"os"

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

func main() {
4 changes: 2 additions & 2 deletions files_api_test.go
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@ import (
"testing"
"time"

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

func TestFileBytesUpload(t *testing.T) {
4 changes: 2 additions & 2 deletions files_test.go
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ import (
"os"
"testing"

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

func TestFileBytesUploadWithFailingFormBuilder(t *testing.T) {
4 changes: 2 additions & 2 deletions fine_tunes_test.go
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ import (
"net/http"
"testing"

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

const testFineTuneID = "fine-tune-id"
4 changes: 2 additions & 2 deletions fine_tuning_job_test.go
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ import (
"net/http"
"testing"

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

const testFineTuninigJobID = "fine-tuning-job-id"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/sashabaranov/go-openai
module github.com/lantiancai/go-openai

go 1.18
4 changes: 2 additions & 2 deletions image_api_test.go
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ import (
"testing"
"time"

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

func TestImages(t *testing.T) {
4 changes: 2 additions & 2 deletions image_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package openai //nolint:testpackage // testing private field

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

"context"
"fmt"
4 changes: 2 additions & 2 deletions internal/error_accumulator_test.go
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ import (
"errors"
"testing"

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

func TestErrorAccumulatorBytes(t *testing.T) {
2 changes: 1 addition & 1 deletion internal/form_builder_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package openai //nolint:testpackage // testing private field

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

"bytes"
"errors"
2 changes: 1 addition & 1 deletion internal/test/helpers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package test

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

"net/http"
"os"
2 changes: 1 addition & 1 deletion jsonschema/json_test.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (
"reflect"
"testing"

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

func TestDefinition_MarshalJSON(t *testing.T) {
2 changes: 1 addition & 1 deletion jsonschema/validate_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package jsonschema_test
import (
"testing"

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

func Test_Validate(t *testing.T) {
6 changes: 3 additions & 3 deletions messages_test.go
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@ import (
"net/http"
"testing"

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

var emptyStr = ""
4 changes: 2 additions & 2 deletions models_test.go
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ import (
"testing"
"time"

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

const testFineTuneModelID = "fine-tune-model-id"
4 changes: 2 additions & 2 deletions moderation_test.go
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ import (
"testing"
"time"

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

// TestModeration Tests the moderations endpoint of the API using the mocked server.
4 changes: 2 additions & 2 deletions openai_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package openai_test

import (
"github.com/sashabaranov/go-openai"
"github.com/sashabaranov/go-openai/internal/test"
"github.com/lantiancai/go-openai"
"github.com/lantiancai/go-openai/internal/test"
)

func setupOpenAITestServer() (client *openai.Client, server *test.ServerTest, teardown func()) {
4 changes: 2 additions & 2 deletions run_test.go
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ package openai_test
import (
"context"

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

"encoding/json"
"fmt"
6 changes: 3 additions & 3 deletions speech_test.go
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@ import (
"path/filepath"
"testing"

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

func TestSpeechIntegration(t *testing.T) {
2 changes: 1 addition & 1 deletion stream_reader.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (
"net/http"
"regexp"

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

var (
6 changes: 3 additions & 3 deletions stream_reader_test.go
Original file line number Diff line number Diff line change
@@ -6,9 +6,9 @@ import (
"errors"
"testing"

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

var errTestUnmarshalerFailed = errors.New("test unmarshaler failed")
4 changes: 2 additions & 2 deletions stream_test.go
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@ import (
"testing"
"time"

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

func TestCompletionsStreamWrongModel(t *testing.T) {
4 changes: 2 additions & 2 deletions thread_test.go
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ import (
"net/http"
"testing"

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

// TestThread Tests the thread endpoint of the API using the mocked server.
4 changes: 2 additions & 2 deletions vector_store_test.go
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ package openai_test
import (
"context"

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

"encoding/json"
"fmt"