29 lines
742 B
Go
29 lines
742 B
Go
package structuredoutput
|
|
|
|
import "strings"
|
|
|
|
var malformedMarkers = []string{
|
|
"malformed structured output",
|
|
"decode structured output:",
|
|
"decode provider response envelope:",
|
|
"provider response missing choices",
|
|
"provider response missing assistant message content",
|
|
"provider response assistant message content is empty",
|
|
"provider response assistant message content is not valid JSON",
|
|
}
|
|
|
|
// IsMalformedError reports whether err matches provider malformed
|
|
// structured-output failure markers that should be downgraded.
|
|
func IsMalformedError(err error) bool {
|
|
if err == nil {
|
|
return false
|
|
}
|
|
msg := err.Error()
|
|
for _, marker := range malformedMarkers {
|
|
if strings.Contains(msg, marker) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|