Store into memory conversation before resetting it
Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
models/
|
models/
|
||||||
data/
|
data/
|
||||||
example/webui/pool
|
example/webui/pool
|
||||||
|
uploads/
|
||||||
@@ -154,6 +154,18 @@ func (a *Agent) SetConversation(conv []openai.ChatCompletionMessage) {
|
|||||||
func (a *Agent) ResetConversation() {
|
func (a *Agent) ResetConversation() {
|
||||||
a.Lock()
|
a.Lock()
|
||||||
defer a.Unlock()
|
defer a.Unlock()
|
||||||
|
|
||||||
|
// store into memory the conversation before pruning it
|
||||||
|
if a.options.enableKB {
|
||||||
|
for _, message := range a.currentConversation {
|
||||||
|
if message.Role == "user" {
|
||||||
|
if err := a.options.ragdb.Store(message.Content); err != nil {
|
||||||
|
xlog.Error("Error storing into memory", "error", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
a.currentConversation = []openai.ChatCompletionMessage{}
|
a.currentConversation = []openai.ChatCompletionMessage{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user