mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-17 09:24:36 +08:00
change v1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
@@ -101,3 +102,16 @@ func (h *chatHistory) CleanOld(maxAge time.Duration) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Agent) getLastAssistantReply(userID int64) string {
|
||||
if a == nil || a.history == nil {
|
||||
return ""
|
||||
}
|
||||
msgs := a.history.Get(userID)
|
||||
for i := len(msgs) - 1; i >= 0; i-- {
|
||||
if strings.EqualFold(strings.TrimSpace(msgs[i].Role), "assistant") {
|
||||
return strings.TrimSpace(msgs[i].Content)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user