Description
Describe the bug
Trying to transcribe an mp3 file which happens to be larger than expected, using the snippet below:
config := openai.DefaultConfig("<token>")
client := openai.NewClientWithConfig(config)
req := openai.AudioRequest{
Model: openai.Whisper1,
FilePath: "music.mp3",
}
resp, err := client.CreateTranscription(context.TODO(), req)
if err != nil {
fmt.Printf("Transcription error: %v\n", err)
return
}
fmt.Println(resp.Text)
the code returns this error:
error, status code: 413, message: invalid character '<' looking for beginning of value
OK, what is it all about? Is 413 an HTTP status code? where did '<' come from?
So I started to investigate, yep, 413 is an HTTP status code, but the error comes after it message: invalid character '<' looking for beginning of value
, has nothing about the 413, and comes from json package which expects a json response.
it's a little bit confusing.
logging the error inside handleErrorResp method ([email protected]/client.go:259
):
<html>
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx</center>
</body>
</html>
Expected behavior
I expected handleErrorResp returns a clear error like Request Entity Too Large
before it tries to unmarshal an HTML, leading to a wrong second error.
Environment (please complete the following information):
- go-openai version: v1.26.0
- Go version: v1.21.0
- OpenAI API version: v1
- OS: macOS
Additional context
I don't exactly remember but I think I had the same issue with rate limit related errors earlier.