Fix: last msg duplication
This commit is contained in:
5
bot.go
5
bot.go
@@ -91,11 +91,8 @@ func cleanToolCalls(messages []models.RoleMsg) []models.RoleMsg {
|
|||||||
cleaned := make([]models.RoleMsg, 0, len(messages))
|
cleaned := make([]models.RoleMsg, 0, len(messages))
|
||||||
for i, msg := range messages {
|
for i, msg := range messages {
|
||||||
// recognize the message as the tool call and remove it
|
// recognize the message as the tool call and remove it
|
||||||
if msg.ToolCallID == "" {
|
|
||||||
cleaned = append(cleaned, msg)
|
|
||||||
}
|
|
||||||
// tool call in last msg should stay
|
// tool call in last msg should stay
|
||||||
if i == len(messages)-1 {
|
if msg.ToolCallID == "" || i == len(messages)-1 {
|
||||||
cleaned = append(cleaned, msg)
|
cleaned = append(cleaned, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user