fix(audio): fix audioTextResponse decode (#638)

* fix(audio): fix audioTextResponse decode

* test(audio): add audioTextResponse decode test

* test(audio): simplify code
This commit is contained in:
Qiying Wang
2024-01-18 01:42:07 +08:00
committed by GitHub
parent 4ce03a919a
commit eff8dc1118
2 changed files with 47 additions and 11 deletions

View File

@@ -193,10 +193,14 @@ func decodeResponse(body io.Reader, v any) error {
return nil
}
if result, ok := v.(*string); ok {
return decodeString(body, result)
switch o := v.(type) {
case *string:
return decodeString(body, o)
case *audioTextResponse:
return decodeString(body, &o.Text)
default:
return json.NewDecoder(body).Decode(v)
}
return json.NewDecoder(body).Decode(v)
}
func decodeString(body io.Reader, output *string) error {