Merge pull request #931 from trheyi/main
refactor: Update message handling to ignore progress messages
This commit is contained in:
commit
91cf52632f
2 changed files with 12 additions and 11 deletions
|
|
@ -264,18 +264,19 @@ func (next *NextAction) Execute(c *gin.Context, ctx chatctx.Context, contents *c
|
||||||
return nil, fmt.Errorf("with history error: %s", err.Error())
|
return nil, fmt.Errorf("with history error: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send the progress message from application side instead
|
||||||
// Create a new Text
|
// Create a new Text
|
||||||
// Send loading message and mark as new
|
// Send loading message and mark as new
|
||||||
if !ctx.Silent {
|
// if !ctx.Silent {
|
||||||
msg := chatMessage.New().Map(map[string]interface{}{
|
// msg := chatMessage.New().Map(map[string]interface{}{
|
||||||
"new": true,
|
// "new": true,
|
||||||
"role": "assistant",
|
// "role": "assistant",
|
||||||
"type": "loading",
|
// "type": "loading",
|
||||||
"props": map[string]interface{}{"placeholder": "Calling " + assistant.Name},
|
// "props": map[string]interface{}{"placeholder": "Calling " + assistant.Name},
|
||||||
})
|
// })
|
||||||
msg.Assistant(assistant.ID, assistant.Name, assistant.Avatar)
|
// msg.Assistant(assistant.ID, assistant.Name, assistant.Avatar)
|
||||||
msg.Write(c.Writer)
|
// msg.Write(c.Writer)
|
||||||
}
|
// }
|
||||||
newContents := chatMessage.NewContents()
|
newContents := chatMessage.NewContents()
|
||||||
|
|
||||||
// Update the context id
|
// Update the context id
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,7 @@ func (m *Message) AppendTo(contents *Contents) *Message {
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
|
|
||||||
case "loading", "error", "action": // Ignore loading, action and error messages
|
case "loading", "error", "action", "progress": // Ignore progress, loading, action and error messages
|
||||||
return m
|
return m
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue