Download internal/httpapi/openai/shared/upstream_empty.go from a3216/ds2api: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/a3216/ds2api/resolve/ce5a019598af8a3a8fa70d3880098df3e850ecd7/internal/httpapi/openai/shared/upstream_empty.go
- Command line
-
hf download hf://spaces/a3216/ds2api@ce5a019598af8a3a8fa70d3880098df3e850ecd7/internal/httpapi/openai/shared/upstream_empty.go
-
curl -L -o upstream_empty.go https://huggingface.co/spaces/a3216/ds2api/resolve/ce5a019598af8a3a8fa70d3880098df3e850ecd7/internal/httpapi/openai/shared/upstream_empty.go
1.04 kB
| package shared | |
| import ( | |
| "net/http" | |
| "strings" | |
| ) | |
| func ShouldWriteUpstreamEmptyOutputError(text, thinking string) bool { | |
| return strings.TrimSpace(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 account hit a rate limit and returned reasoning without visible output.", "upstream_empty_output" | |
| } | |
| return http.StatusServiceUnavailable, "Upstream service is unavailable and returned no output.", "upstream_unavailable" | |
| } | |
| func WriteUpstreamEmptyOutputError(w http.ResponseWriter, text, thinking string, contentFilter bool) bool { | |
| if !ShouldWriteUpstreamEmptyOutputError(text, thinking) { | |
| return false | |
| } | |
| status, message, code := UpstreamEmptyOutputDetail(contentFilter, text, thinking) | |
| WriteOpenAIErrorWithCode(w, status, message, code) | |
| return true | |
| } | |