Skip to content
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

go 1.19.2 build error on mac and detail error is : [email protected]/batch.go:205:16: undefined: errors.Join #774

Closed
hachi-zzq opened this issue Jun 21, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@hachi-zzq
Copy link

hachi-zzq commented Jun 21, 2024

Your issue may already be reported!
Please search on the issue tracker before creating one.

Describe the bug

when my golang version is go1.19.2,i run the example code about CreateChatCompletion, report this error

../../../go/pkg/mod/github.com/sashabaranov/[email protected]/batch.go:205:16: undefined: errors.Join

To Reproduce
my example code is

package main

import (
	"context"
	"fmt"
	openai "github.com/sashabaranov/go-openai"
)

func main() {
	client := openai.NewClient("sk-xxxE")
	resp, err := client.CreateChatCompletion(
		context.Background(),
		openai.ChatCompletionRequest{
			Model: openai.GPT4o,
			Messages: []openai.ChatCompletionMessage{
				{
					Role:    openai.ChatMessageRoleUser,
					Content: "hello!",
				},
			},
		},
	)

	if err != nil {
		fmt.Printf("ChatCompletion error: %v\n", err)
		return
	}

	fmt.Println(resp.Choices[0].Message.Content)
}

and the result is
image

my project is run on mac apple kernal , the detail is
Apple M2 Pro
Mac OS Ventura 13.6.1

my go version is
go version go1.19.2 darwin/arm64

Screenshots/Logs
image
image

Environment (please complete the following information):

  • go-openai version: v1.26.0
  • Go version: go1.19.2 darwin/arm64
  • OpenAI API version: v1
  • OS: Mac OS Ventura 13.6.1

Additional context
there is no error when i run it on 1.18 or 1.20

@hachi-zzq hachi-zzq added the bug Something isn't working label Jun 21, 2024
@sashabaranov
Copy link
Owner

Thank you for reporting that!

errors.Join was indeed introduced in 1.20, and we either need to bump a minimal supported version to 1.20 or use something else there.

cc @eiixy

@sashabaranov
Copy link
Owner

@hachi-zzq fixed in v1.26.1 https://github.com/sashabaranov/go-openai/releases/tag/v1.26.1

@hachi-zzq
Copy link
Author

@sashabaranov thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants