-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
26 lines (21 loc) · 717 Bytes
/
utils.py
File metadata and controls
26 lines (21 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import json
from pathlib import Path
import streamlit as st
from config import CONVERSATIONS_FILE
def save_conversations():
with open(CONVERSATIONS_FILE, 'w') as f:
json.dump(st.session_state.conversations, f, indent=2)
def load_conversations():
if CONVERSATIONS_FILE.exists():
with open(CONVERSATIONS_FILE, 'r') as f:
st.session_state.conversations = json.load(f)
return
st.session_state.conversations = []
def load_personas(path: Path):
if not path.exists():
return []
personas = json.loads(path.read_text())
return personas
def save_personas(personas, path: Path):
with open(path, 'w') as f:
json.dump(personas, f, indent=2)