diff options
author | Grail Finder <wohilas@gmail.com> | 2024-12-08 14:18:16 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2024-12-08 14:18:16 +0300 |
commit | bdd40ea8df60b6b161da3c1d201e9ec05ef743d1 (patch) | |
tree | 13fe8eff8a4c3415d117e6ed53e4e9fc347df95b /session.go | |
parent | 55010bb70439260bf58cdd163d0041e00254c06b (diff) |
Feat: export chat to json file;
Diffstat (limited to 'session.go')
-rw-r--r-- | session.go | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "os" "os/exec" "strings" "time" @@ -25,6 +26,14 @@ func historyToSJSON(msgs []models.RoleMsg) (string, error) { return string(data), nil } +func exportChat() error { + data, err := json.MarshalIndent(chatBody.Messages, "", " ") + if err != nil { + return err + } + return os.WriteFile(activeChatName+".json", data, 0666) +} + func updateStorageChat(name string, msgs []models.RoleMsg) error { var err error chat, ok := chatMap[name] |