mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 00:45:29 +08:00
refactor: remove thinking content from empty output validation logic to enforce stricter completion requirements
This commit is contained in:
@@ -206,11 +206,6 @@ func ValidateTurn(turn Turn, policy promptcompat.ToolChoicePolicy) *OutputError
|
||||
if strings.TrimSpace(turn.Text) != "" {
|
||||
return nil
|
||||
}
|
||||
// Thinking-only with no visible text is not an immediate error;
|
||||
// the caller should retry via ShouldRetryEmptyOutput first.
|
||||
if strings.TrimSpace(turn.Thinking) != "" {
|
||||
return nil
|
||||
}
|
||||
status, message, code := UpstreamEmptyOutputDetail(turn.ContentFilter, turn.Text, turn.Thinking)
|
||||
return &OutputError{Status: status, Message: message, Code: code}
|
||||
}
|
||||
|
||||
@@ -151,8 +151,7 @@ func shouldRetryChatNonStream(result chatNonStreamResult, attempts int) bool {
|
||||
attempts < emptyOutputRetryMaxAttempts() &&
|
||||
!result.contentFilter &&
|
||||
result.detectedCalls == 0 &&
|
||||
strings.TrimSpace(result.text) == "" &&
|
||||
strings.TrimSpace(result.thinking) == ""
|
||||
strings.TrimSpace(result.text) == ""
|
||||
}
|
||||
|
||||
func (h *Handler) handleStreamWithRetry(w http.ResponseWriter, r *http.Request, a *auth.RequestAuth, resp *http.Response, payload map[string]any, pow, completionID, model, finalPrompt string, refFileTokens int, thinkingEnabled, searchEnabled bool, toolNames []string, toolsRaw any, toolChoice promptcompat.ToolChoicePolicy, historySession *chatHistorySession) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func ShouldWriteUpstreamEmptyOutputError(text, thinking string) bool {
|
||||
return strings.TrimSpace(text) == "" && strings.TrimSpace(thinking) == ""
|
||||
return strings.TrimSpace(text) == ""
|
||||
}
|
||||
|
||||
func UpstreamEmptyOutputDetail(contentFilter bool, text, thinking string) (int, string, string) {
|
||||
|
||||
Reference in New Issue
Block a user