Add long term memory

This commit is contained in:
mudler
2024-12-17 19:53:07 +01:00
parent d053dc249c
commit 2561f2f175
6 changed files with 104 additions and 47 deletions

View File

@@ -68,6 +68,7 @@ func (a *Agent) decision(
Tools: tools,
ToolChoice: toolchoice,
}
resp, err := a.client.CreateChatCompletion(ctx, decision)
if err != nil {
return nil, err
@@ -96,6 +97,14 @@ func (m Messages) ToOpenAI() []openai.ChatCompletionMessage {
return []openai.ChatCompletionMessage(m)
}
func (m Messages) String() string {
s := ""
for _, cc := range m {
s += cc.Role + ": " + cc.Content + "\n"
}
return s
}
func (m Messages) Exist(content string) bool {
for _, cc := range m {
if cc.Content == content {