mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 21:10:18 +09:00
Fix(Chat):修复带有reasoning_content信息看不到回答内容的问题
This commit is contained in:
parent
72f3a45366
commit
6fb6b6a229
@ -13,6 +13,7 @@ type ChatInstance struct {
|
|||||||
Endpoint string
|
Endpoint string
|
||||||
ApiKey string
|
ApiKey string
|
||||||
isFirstReasoning bool
|
isFirstReasoning bool
|
||||||
|
isReasonOver bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ChatInstance) GetEndpoint() string {
|
func (c *ChatInstance) GetEndpoint() string {
|
||||||
@ -90,7 +91,18 @@ func (c *ChatInstance) ProcessLine(data string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delta := form.Choices[0].Delta
|
delta := form.Choices[0].Delta
|
||||||
|
|
||||||
if delta.ReasoningContent != nil {
|
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
|
content := *delta.ReasoningContent
|
||||||
// replace double newlines with single newlines for markdown
|
// replace double newlines with single newlines for markdown
|
||||||
if strings.Contains(content, "\n\n") {
|
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 {
|
func (c *ChatInstance) CreateStreamChatRequest(props *adaptercommon.ChatProps, callback globals.Hook) error {
|
||||||
c.isFirstReasoning = true
|
c.isFirstReasoning = true
|
||||||
|
c.isReasonOver = false
|
||||||
err := utils.EventScanner(&utils.EventScannerProps{
|
err := utils.EventScanner(&utils.EventScannerProps{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Uri: c.GetChatEndpoint(),
|
Uri: c.GetChatEndpoint(),
|
||||||
|
Loading…
Reference in New Issue
Block a user