fix: filter empty chunk

This commit is contained in:
Zhang Minghan 2024-02-18 20:52:38 +08:00
parent 6259937347
commit e14fb02fb9
2 changed files with 9 additions and 1 deletions

5
globals/method.go Normal file
View File

@ -0,0 +1,5 @@
package globals
func (c *Chunk) IsEmpty() bool {
return len(c.Content) == 0 && c.ToolCall == nil && c.FunctionCall == nil
}

View File

@ -198,7 +198,10 @@ func sendStreamTranshipmentResponse(c *gin.Context, form RelayForm, messages []g
cache, buffer, group, getChatProps(form, messages, buffer, plan),
func(data *globals.Chunk) error {
buffer.WriteChunk(data)
partial <- getStreamTranshipmentForm(id, created, form, data, buffer, false, nil)
if !data.IsEmpty() {
partial <- getStreamTranshipmentForm(id, created, form, data, buffer, false, nil)
}
return nil
},
)