go-openai
go-openai copied to clipboard
Remote service always return EOF
I'm trying to fetch a response from remote chatGPT service with following code:
func Chat3(msg string) string {
c := openai.NewClient("my token")
ctx := context.Background()
req := openai.CompletionRequest{
Model: openai.GPT3Ada,
MaxTokens: 5,
Prompt: msg,
}
resp, err := c.CreateCompletion(ctx, req)
if err != nil {
fmt.Printf("Completion error: %v\n", err)
return ""
}
fmt.Println(resp.Choices[0].Text)
return resp.Choices[0].Text
}
But the code above always gives me an error: Completion error: Post "https://api.openai.com/v1/completions": EOF
Any idea about it? Thank you.
我也遇到了
@goldkyo I don't get an error when I try the same code.
Here's a gist I wrote to test it out: https://gist.github.com/rexposadas/5b8cf1737f5436a949eb3f46456a5a11
Maybe it was an outage on the server when you were executing your code? (this is a wild guess and probably not true)
@rexposadas Sorry for the late update, I found out that the root cause of the issue is in my network environment. Just miss leaded by that EOF, which makes me considering about a data error. Thank you for helping.
@goldkyo Sounds good. We can probably close this issue.
Yes, sure. Done, thank you.
@goldkyo What environmental issue caused you to get that EOF?