diff --git a/neo/assistant/api.go b/neo/assistant/api.go index 2e338662..9f1dd423 100644 --- a/neo/assistant/api.go +++ b/neo/assistant/api.go @@ -433,6 +433,7 @@ func (ast *Assistant) streamChat( end.Silent = ctx.Silent end.End = time.Now().UnixNano() end.Begin = beganAt + end.ToolID = tokenID end.Callback(cb).Write(c.Writer) end.AppendTo(contents) @@ -491,10 +492,11 @@ func (ast *Assistant) streamChat( currentMessageID = params.MessageID msg.ID = params.MessageID msg.Type = params.Token - msg.Text = "" // clear the text - msg.Props = map[string]interface{}{"text": params.Text} // Update props + msg.Text = "" // clear the text + msg.Props = map[string]interface{}{"text": params.Text, "id": params.TokenID} // Update props msg.Begin = params.BeganAt msg.End = params.EndAt + msg.ToolID = params.TokenID // End of the token clear the text if params.Begin { @@ -570,6 +572,7 @@ func (ast *Assistant) streamChat( if msg.Type == "think" || msg.Type == "tool" { output.Begin = msg.Begin output.End = msg.End + output.ToolID = msg.ToolID } output.Callback(cb).Write(c.Writer) diff --git a/neo/message/message.go b/neo/message/message.go index e42d7844..897aeb5b 100644 --- a/neo/message/message.go +++ b/neo/message/message.go @@ -21,6 +21,7 @@ var locker = sync.Mutex{} // Message the message type Message struct { ID string `json:"id,omitempty"` // id for the message + ToolID string `json:"tool_id,omitempty"` // tool_id for the message Text string `json:"text,omitempty"` // text content Type string `json:"type,omitempty"` // error, text, plan, table, form, page, file, video, audio, image, markdown, json ... Props map[string]interface{} `json:"props,omitempty"` // props for the types