From 57e8389afd5bda017e563d056ff00493078986b7 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 19 Apr 2025 15:38:12 +0800 Subject: [PATCH] refactor: Update message handling to ignore progress messages - Modify message handling logic to include "progress" in the list of ignored message types alongside "loading", "error", and "action". - Comment out the loading message sending logic in the Execute method to streamline the process and improve clarity in message flow. --- neo/assistant/api.go | 21 +++++++++++---------- neo/message/message.go | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/neo/assistant/api.go b/neo/assistant/api.go index 9f1dd423..95258bf7 100644 --- a/neo/assistant/api.go +++ b/neo/assistant/api.go @@ -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()) } + // Send the progress message from application side instead // Create a new Text // Send loading message and mark as new - if !ctx.Silent { - msg := chatMessage.New().Map(map[string]interface{}{ - "new": true, - "role": "assistant", - "type": "loading", - "props": map[string]interface{}{"placeholder": "Calling " + assistant.Name}, - }) - msg.Assistant(assistant.ID, assistant.Name, assistant.Avatar) - msg.Write(c.Writer) - } + // if !ctx.Silent { + // msg := chatMessage.New().Map(map[string]interface{}{ + // "new": true, + // "role": "assistant", + // "type": "loading", + // "props": map[string]interface{}{"placeholder": "Calling " + assistant.Name}, + // }) + // msg.Assistant(assistant.ID, assistant.Name, assistant.Avatar) + // msg.Write(c.Writer) + // } newContents := chatMessage.NewContents() // Update the context id diff --git a/neo/message/message.go b/neo/message/message.go index 897aeb5b..4afb92d3 100644 --- a/neo/message/message.go +++ b/neo/message/message.go @@ -432,7 +432,7 @@ func (m *Message) AppendTo(contents *Contents) *Message { } 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 default: