From b0a4614574d4850c229d9e8527cf863022240ce6 Mon Sep 17 00:00:00 2001 From: PandaJu Date: Tue, 11 Feb 2025 09:26:26 +0800 Subject: [PATCH] =?UTF-8?q?Fix(Chat):=E4=BF=AE=E5=A4=8D=E5=B8=A6=E6=9C=89r?= =?UTF-8?q?easoning=5Fcontent=E4=BF=A1=E6=81=AF=E7=9C=8B=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E5=9B=9E=E7=AD=94=E5=86=85=E5=AE=B9=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapter/deepseek/chat.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/adapter/deepseek/chat.go b/adapter/deepseek/chat.go index 2c5753f..332895d 100644 --- a/adapter/deepseek/chat.go +++ b/adapter/deepseek/chat.go @@ -13,6 +13,7 @@ type ChatInstance struct { Endpoint string ApiKey string isFirstReasoning bool + isReasonOver bool } func (c *ChatInstance) GetEndpoint() string { @@ -90,7 +91,18 @@ func (c *ChatInstance) ProcessLine(data string) (string, error) { } delta := form.Choices[0].Delta + if delta.ReasoningContent != nil { + if *delta.ReasoningContent == "" && delta.Content != "" { + if !c.isReasonOver { + c.isReasonOver = true + + return fmt.Sprintf("\n\n%s", delta.Content), nil + } + } + } + + if delta.ReasoningContent != nil && delta.Content == "" { content := *delta.ReasoningContent // replace double newlines with single newlines for markdown if strings.Contains(content, "\n\n") { @@ -146,6 +158,7 @@ func (c *ChatInstance) CreateChatRequest(props *adaptercommon.ChatProps) (string func (c *ChatInstance) CreateStreamChatRequest(props *adaptercommon.ChatProps, callback globals.Hook) error { c.isFirstReasoning = true + c.isReasonOver = false err := utils.EventScanner(&utils.EventScannerProps{ Method: "POST", Uri: c.GetChatEndpoint(),