From 5721c52c0d17e1df14dac808a9c852815e31963c Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sun, 2 Mar 2025 21:27:11 +0100 Subject: [PATCH] use date for file name prefix --- pkg/localrag/client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/localrag/client.go b/pkg/localrag/client.go index f54b18d..0dfd1c9 100644 --- a/pkg/localrag/client.go +++ b/pkg/localrag/client.go @@ -13,6 +13,7 @@ import ( "net/http" "os" "path/filepath" + "time" "github.com/mudler/LocalAgent/core/agent" "github.com/mudler/LocalAgent/pkg/xlog" @@ -64,8 +65,11 @@ func (c *WrappedClient) Store(s string) error { // the Client API of LocalRAG takes only files at the moment. // So we take the string that we want to store, write it to a file, and then store the file. + // get current date and time for file name + t := time.Now() + dateTime := t.Format("2006-01-02-15-04-05") hash := md5.Sum([]byte(s)) - fileName := hex.EncodeToString(hash[:]) + ".txt" + fileName := fmt.Sprintf("%s-%s.%s", dateTime, hex.EncodeToString(hash[:]), "txt") xlog.Debug("Storing string in LocalRAG", "collection", c.collection, "fileName", fileName)