Merge pull request #930 from trheyi/main
feat: Enhance message structure with ToolID for improved context
This commit is contained in:
commit
e4b76a9a08
2 changed files with 6 additions and 2 deletions
|
|
@ -433,6 +433,7 @@ func (ast *Assistant) streamChat(
|
||||||
end.Silent = ctx.Silent
|
end.Silent = ctx.Silent
|
||||||
end.End = time.Now().UnixNano()
|
end.End = time.Now().UnixNano()
|
||||||
end.Begin = beganAt
|
end.Begin = beganAt
|
||||||
|
end.ToolID = tokenID
|
||||||
|
|
||||||
end.Callback(cb).Write(c.Writer)
|
end.Callback(cb).Write(c.Writer)
|
||||||
end.AppendTo(contents)
|
end.AppendTo(contents)
|
||||||
|
|
@ -492,9 +493,10 @@ func (ast *Assistant) streamChat(
|
||||||
msg.ID = params.MessageID
|
msg.ID = params.MessageID
|
||||||
msg.Type = params.Token
|
msg.Type = params.Token
|
||||||
msg.Text = "" // clear the text
|
msg.Text = "" // clear the text
|
||||||
msg.Props = map[string]interface{}{"text": params.Text} // Update props
|
msg.Props = map[string]interface{}{"text": params.Text, "id": params.TokenID} // Update props
|
||||||
msg.Begin = params.BeganAt
|
msg.Begin = params.BeganAt
|
||||||
msg.End = params.EndAt
|
msg.End = params.EndAt
|
||||||
|
msg.ToolID = params.TokenID
|
||||||
|
|
||||||
// End of the token clear the text
|
// End of the token clear the text
|
||||||
if params.Begin {
|
if params.Begin {
|
||||||
|
|
@ -570,6 +572,7 @@ func (ast *Assistant) streamChat(
|
||||||
if msg.Type == "think" || msg.Type == "tool" {
|
if msg.Type == "think" || msg.Type == "tool" {
|
||||||
output.Begin = msg.Begin
|
output.Begin = msg.Begin
|
||||||
output.End = msg.End
|
output.End = msg.End
|
||||||
|
output.ToolID = msg.ToolID
|
||||||
}
|
}
|
||||||
|
|
||||||
output.Callback(cb).Write(c.Writer)
|
output.Callback(cb).Write(c.Writer)
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ var locker = sync.Mutex{}
|
||||||
// Message the message
|
// Message the message
|
||||||
type Message struct {
|
type Message struct {
|
||||||
ID string `json:"id,omitempty"` // id for the message
|
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
|
Text string `json:"text,omitempty"` // text content
|
||||||
Type string `json:"type,omitempty"` // error, text, plan, table, form, page, file, video, audio, image, markdown, json ...
|
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
|
Props map[string]interface{} `json:"props,omitempty"` // props for the types
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue