mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-20 16:07:47 +08:00
refactor: remove legacy compatibility configuration and UI components
This commit is contained in:
@@ -23,7 +23,6 @@ type DeepSeekCaller interface {
|
||||
|
||||
type ConfigReader interface {
|
||||
ModelAliases() map[string]string
|
||||
CompatStripReferenceMarkers() bool
|
||||
CurrentInputFileEnabled() bool
|
||||
CurrentInputFileMinChars() int
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ type mockClaudeConfig struct {
|
||||
}
|
||||
|
||||
func (m mockClaudeConfig) ModelAliases() map[string]string { return m.aliases }
|
||||
func (mockClaudeConfig) CompatStripReferenceMarkers() bool { return true }
|
||||
func (mockClaudeConfig) CurrentInputFileEnabled() bool { return true }
|
||||
func (mockClaudeConfig) CurrentInputFileMinChars() int { return 0 }
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ func (h *Handler) handleClaudeDirect(w http.ResponseWriter, r *http.Request) boo
|
||||
return true
|
||||
}
|
||||
result, outErr := completionruntime.ExecuteNonStreamWithRetry(r.Context(), h.DS, a, norm.Standard, completionruntime.Options{
|
||||
StripReferenceMarkers: h.compatStripReferenceMarkers(),
|
||||
StripReferenceMarkers: stripReferenceMarkersEnabled(),
|
||||
RetryEnabled: true,
|
||||
CurrentInputFile: h.Store,
|
||||
})
|
||||
@@ -290,7 +290,7 @@ func (h *Handler) handleClaudeStreamRealtime(w http.ResponseWriter, r *http.Requ
|
||||
messages,
|
||||
thinkingEnabled,
|
||||
searchEnabled,
|
||||
h.compatStripReferenceMarkers(),
|
||||
stripReferenceMarkersEnabled(),
|
||||
toolNames,
|
||||
toolsRaw,
|
||||
buildClaudePromptTokenText(messages, thinkingEnabled),
|
||||
|
||||
@@ -21,11 +21,8 @@ type Handler struct {
|
||||
OpenAI OpenAIChatRunner
|
||||
}
|
||||
|
||||
func (h *Handler) compatStripReferenceMarkers() bool {
|
||||
if h == nil || h.Store == nil {
|
||||
return true
|
||||
}
|
||||
return h.Store.CompatStripReferenceMarkers()
|
||||
func stripReferenceMarkersEnabled() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -14,9 +14,8 @@ type claudeProxyStoreStub struct {
|
||||
|
||||
func (s claudeProxyStoreStub) ModelAliases() map[string]string { return s.aliases }
|
||||
|
||||
func (claudeProxyStoreStub) CompatStripReferenceMarkers() bool { return true }
|
||||
func (claudeProxyStoreStub) CurrentInputFileEnabled() bool { return true }
|
||||
func (claudeProxyStoreStub) CurrentInputFileMinChars() int { return 0 }
|
||||
func (claudeProxyStoreStub) CurrentInputFileEnabled() bool { return true }
|
||||
func (claudeProxyStoreStub) CurrentInputFileMinChars() int { return 0 }
|
||||
|
||||
type openAIProxyStub struct {
|
||||
status int
|
||||
|
||||
@@ -133,6 +133,9 @@ func (s *claudeStreamRuntime) finalize(stopReason string) {
|
||||
ToolsRaw: s.toolsRaw,
|
||||
})
|
||||
finalText := turn.Text
|
||||
outcome := assistantturn.FinalizeTurn(turn, assistantturn.FinalizeOptions{
|
||||
AlreadyEmittedToolCalls: s.toolCallsDetected,
|
||||
})
|
||||
|
||||
if s.bufferToolContent && !s.toolCallsDetected {
|
||||
if len(turn.ToolCalls) > 0 {
|
||||
@@ -169,7 +172,7 @@ func (s *claudeStreamRuntime) finalize(stopReason string) {
|
||||
}
|
||||
}
|
||||
|
||||
if s.toolCallsDetected {
|
||||
if outcome.HasToolCalls {
|
||||
stopReason = "tool_use"
|
||||
}
|
||||
|
||||
@@ -180,7 +183,7 @@ func (s *claudeStreamRuntime) finalize(stopReason string) {
|
||||
"stop_sequence": nil,
|
||||
},
|
||||
"usage": map[string]any{
|
||||
"output_tokens": turn.Usage.OutputTokens,
|
||||
"output_tokens": outcome.Usage.OutputTokens,
|
||||
},
|
||||
})
|
||||
s.send("message_stop", map[string]any{"type": "message_stop"})
|
||||
|
||||
@@ -23,9 +23,8 @@ type streamStatusClaudeStoreStub struct{}
|
||||
|
||||
func (streamStatusClaudeStoreStub) ModelAliases() map[string]string { return nil }
|
||||
|
||||
func (streamStatusClaudeStoreStub) CompatStripReferenceMarkers() bool { return true }
|
||||
func (streamStatusClaudeStoreStub) CurrentInputFileEnabled() bool { return true }
|
||||
func (streamStatusClaudeStoreStub) CurrentInputFileMinChars() int { return 0 }
|
||||
func (streamStatusClaudeStoreStub) CurrentInputFileEnabled() bool { return true }
|
||||
func (streamStatusClaudeStoreStub) CurrentInputFileMinChars() int { return 0 }
|
||||
|
||||
func captureClaudeStatusMiddleware(statuses *[]int) func(http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
|
||||
Reference in New Issue
Block a user