mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-17 22:55:10 +08:00
fix: retry thinking-only empty outputs, centralize reference marker stripping
- ValidateTurn no longer errors on thinking-only responses, deferring to ShouldRetryEmptyOutput which now also covers thinking-only outputs. - Empty output retry uses multi-turn follow-up with a regeneration prompt suffix and parent_message_id in the same DeepSeek session. - Centralize StripReferenceMarkersEnabled into textclean package to eliminate duplicated hardcoded booleans across 4 protocol handlers. - Log a deprecation warning when the legacy "compat" config key is used. - Document thinking-only retry and reference marker stripping in API.md. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"ds2api/internal/config"
|
||||
dsprotocol "ds2api/internal/deepseek/protocol"
|
||||
"ds2api/internal/textclean"
|
||||
"ds2api/internal/util"
|
||||
)
|
||||
|
||||
@@ -22,7 +23,7 @@ type Handler struct {
|
||||
}
|
||||
|
||||
func stripReferenceMarkersEnabled() bool {
|
||||
return true
|
||||
return textclean.StripReferenceMarkersEnabled()
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
||||
"ds2api/internal/textclean"
|
||||
"ds2api/internal/util"
|
||||
)
|
||||
|
||||
@@ -19,7 +20,7 @@ type Handler struct {
|
||||
|
||||
//nolint:unused // used by native Gemini stream/non-stream runtime helpers.
|
||||
func stripReferenceMarkersEnabled() bool {
|
||||
return true
|
||||
return textclean.StripReferenceMarkersEnabled()
|
||||
}
|
||||
|
||||
func RegisterRoutes(r chi.Router, h *Handler) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"ds2api/internal/httpapi/openai/history"
|
||||
"ds2api/internal/httpapi/openai/shared"
|
||||
"ds2api/internal/promptcompat"
|
||||
"ds2api/internal/textclean"
|
||||
"ds2api/internal/toolcall"
|
||||
"ds2api/internal/toolstream"
|
||||
)
|
||||
@@ -36,7 +37,7 @@ type streamLease struct {
|
||||
}
|
||||
|
||||
func stripReferenceMarkersEnabled() bool {
|
||||
return true
|
||||
return textclean.StripReferenceMarkersEnabled()
|
||||
}
|
||||
|
||||
func (h *Handler) applyCurrentInputFile(ctx context.Context, a *auth.RequestAuth, stdReq promptcompat.StandardRequest) (promptcompat.StandardRequest, error) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"ds2api/internal/httpapi/openai/history"
|
||||
"ds2api/internal/httpapi/openai/shared"
|
||||
"ds2api/internal/promptcompat"
|
||||
"ds2api/internal/textclean"
|
||||
"ds2api/internal/toolstream"
|
||||
)
|
||||
|
||||
@@ -29,7 +30,7 @@ type Handler struct {
|
||||
}
|
||||
|
||||
func stripReferenceMarkersEnabled() bool {
|
||||
return true
|
||||
return textclean.StripReferenceMarkersEnabled()
|
||||
}
|
||||
|
||||
func (h *Handler) applyCurrentInputFile(ctx context.Context, a *auth.RequestAuth, stdReq promptcompat.StandardRequest) (promptcompat.StandardRequest, error) {
|
||||
|
||||
Reference in New Issue
Block a user