mirror of
https://github.com/ManyakRus/starter.git
synced 2025-11-28 23:20:10 +02:00
сделал packages.jpg
This commit is contained in:
35
vendor/github.com/sashabaranov/go-openai/error.go
generated
vendored
35
vendor/github.com/sashabaranov/go-openai/error.go
generated
vendored
@@ -3,15 +3,24 @@ package openai
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// APIError provides error information returned by the OpenAI API.
|
||||
// InnerError struct is only valid for Azure OpenAI Service.
|
||||
type APIError struct {
|
||||
Code any `json:"code,omitempty"`
|
||||
Message string `json:"message"`
|
||||
Param *string `json:"param,omitempty"`
|
||||
Type string `json:"type"`
|
||||
HTTPStatusCode int `json:"-"`
|
||||
Code any `json:"code,omitempty"`
|
||||
Message string `json:"message"`
|
||||
Param *string `json:"param,omitempty"`
|
||||
Type string `json:"type"`
|
||||
HTTPStatusCode int `json:"-"`
|
||||
InnerError *InnerError `json:"innererror,omitempty"`
|
||||
}
|
||||
|
||||
// InnerError Azure Content filtering. Only valid for Azure OpenAI Service.
|
||||
type InnerError struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
ContentFilterResults ContentFilterResults `json:"content_filter_result,omitempty"`
|
||||
}
|
||||
|
||||
// RequestError provides informations about generic request errors.
|
||||
@@ -41,7 +50,14 @@ func (e *APIError) UnmarshalJSON(data []byte) (err error) {
|
||||
|
||||
err = json.Unmarshal(rawMap["message"], &e.Message)
|
||||
if err != nil {
|
||||
return
|
||||
// If the parameter field of a function call is invalid as a JSON schema
|
||||
// refs: https://github.com/sashabaranov/go-openai/issues/381
|
||||
var messages []string
|
||||
err = json.Unmarshal(rawMap["message"], &messages)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
e.Message = strings.Join(messages, ", ")
|
||||
}
|
||||
|
||||
// optional fields for azure openai
|
||||
@@ -53,6 +69,13 @@ func (e *APIError) UnmarshalJSON(data []byte) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := rawMap["innererror"]; ok {
|
||||
err = json.Unmarshal(rawMap["innererror"], &e.InnerError)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// optional fields
|
||||
if _, ok := rawMap["param"]; ok {
|
||||
err = json.Unmarshal(rawMap["param"], &e.Param)
|
||||
|
||||
Reference in New Issue
Block a user