Feat: export chat to json file;
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user