fix json marshaling error response of azure openai (#343) (#345)

* fix json marshaling error response of azure openai (#343)

* add a test case for handleErrorResp func (#343)
This commit is contained in:
渡邉祐一 / Yuichi Watanabe
2023-06-09 00:32:03 +09:00
committed by GitHub
parent b8c13e4c01
commit 06b16a7281
3 changed files with 77 additions and 3 deletions

View File

@@ -44,9 +44,13 @@ func (e *APIError) UnmarshalJSON(data []byte) (err error) {
return
}
err = json.Unmarshal(rawMap["type"], &e.Type)
if err != nil {
return
// optional fields for azure openai
// refs: https://github.com/sashabaranov/go-openai/issues/343
if _, ok := rawMap["type"]; ok {
err = json.Unmarshal(rawMap["type"], &e.Type)
if err != nil {
return
}
}
// optional fields