Files
LocalAGI/services/common.go
T
Ettore Di Giacinto be336adf02 feat(dynamic-prompts): add memory tool to dynamic prompt (#256)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
2025-08-04 16:58:11 +02:00

29 lines
788 B
Go

package services
import (
"fmt"
"os"
"github.com/mudler/LocalAGI/pkg/xlog"
)
func memoryPath(agentName string, actionsConfigs map[string]string) string {
// Compose memory file path based on stateDir and agentName, using a subdirectory
memoryFilePath := "memory.json"
if actionsConfigs != nil {
if stateDir, ok := actionsConfigs[ConfigStateDir]; ok && stateDir != "" {
memoryDir := fmt.Sprintf("%s/memory", stateDir)
err := os.MkdirAll(memoryDir, 0755) // ensure the directory exists
if err != nil {
xlog.Error("Error creating memory directory", "error", err)
return memoryFilePath
}
memoryFilePath = fmt.Sprintf("%s/%s.json", memoryDir, agentName)
} else {
memoryFilePath = fmt.Sprintf("%s.memory.json", agentName)
}
}
return memoryFilePath
}