mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-09 10:55:27 +08:00
28 lines
958 B
Go
28 lines
958 B
Go
package openai
|
|
|
|
import "net/http"
|
|
|
|
func shouldWriteUpstreamEmptyOutputError(text string, contentFilter bool) bool {
|
|
return text == ""
|
|
}
|
|
|
|
func upstreamEmptyOutputDetail(contentFilter bool, text, thinking string) (int, string, string) {
|
|
_ = text
|
|
if contentFilter {
|
|
return http.StatusBadRequest, "Upstream content filtered the response and returned no output.", "content_filter"
|
|
}
|
|
if thinking != "" {
|
|
return http.StatusTooManyRequests, "Upstream model returned reasoning without visible output.", "upstream_empty_output"
|
|
}
|
|
return http.StatusTooManyRequests, "Upstream model returned empty output.", "upstream_empty_output"
|
|
}
|
|
|
|
func writeUpstreamEmptyOutputError(w http.ResponseWriter, text string, contentFilter bool) bool {
|
|
if !shouldWriteUpstreamEmptyOutputError(text, contentFilter) {
|
|
return false
|
|
}
|
|
status, message, code := upstreamEmptyOutputDetail(contentFilter, text, "")
|
|
writeOpenAIErrorWithCode(w, status, message, code)
|
|
return true
|
|
}
|