Feat: export chat to json file;

This commit is contained in:
Grail Finder
2024-12-08 14:18:16 +03:00
parent 55010bb704
commit bdd40ea8df
3 changed files with 30 additions and 4 deletions

View File

@@ -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]