go-openai icon indicating copy to clipboard operation
go-openai copied to clipboard

Remote service always return EOF

Open goldkyo opened this issue 1 year ago • 2 comments

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 avatar Mar 21 '23 08:03 goldkyo

我也遇到了

linabellbiu avatar Mar 23 '23 02:03 linabellbiu

@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 avatar Mar 23 '23 17:03 rexposadas

@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 avatar Mar 25 '23 02:03 goldkyo

@goldkyo Sounds good. We can probably close this issue.

rexposadas avatar Mar 25 '23 10:03 rexposadas

Yes, sure. Done, thank you.

goldkyo avatar Mar 25 '23 12:03 goldkyo

@goldkyo What environmental issue caused you to get that EOF?

Derek-yzh avatar Jul 24 '23 06:07 Derek-yzh