Skip to content

Commit

Permalink
Fix(Chat):修复带有reasoning_content信息看不到回答内容的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
PandaJu authored and Sh1n3zZ committed Feb 11, 2025
1 parent 72f3a45 commit 6fb6b6a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions adapter/deepseek/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ChatInstance struct {
Endpoint string
ApiKey string
isFirstReasoning bool
isReasonOver bool
}

func (c *ChatInstance) GetEndpoint() string {
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 6fb6b6a

Please sign in to comment.