From bc662d95fad8eb4cb8825755e99fe0ff7c2f1231 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 29 Jan 2025 16:14:43 +0800 Subject: [PATCH] Improve message filtering in Neo API assistant stream processing - Added filtering for 'function' type messages in requestMessages method - Removed debug print statement in streamChat method - Enhanced message handling to ignore function call messages during processing This change refines the message filtering logic in the Neo API assistant, improving the clarity and efficiency of message stream processing. --- neo/assistant/api.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/neo/assistant/api.go b/neo/assistant/api.go index b42138dd..422f08e2 100644 --- a/neo/assistant/api.go +++ b/neo/assistant/api.go @@ -308,8 +308,6 @@ func (ast *Assistant) streamChat( // msg.Write(c.Writer) // } - fmt.Println("Done", contents.JSON()) - res, hookErr := ast.HookDone(c, ctx, messages, contents) if hookErr == nil && res != nil { @@ -468,6 +466,12 @@ func (ast *Assistant) requestMessages(ctx context.Context, messages []chatMessag length := len(messages) for index, message := range messages { + + // Ignore the function call message + if message.Type == "function" { + continue + } + role := message.Role if role == "" { return nil, fmt.Errorf("role must be string")