STSLP / save_state.py
SreekarB's picture
Upload 7 files
e394327 verified
raw
history blame contribute delete
402 Bytes
import json
import os
SAVE_DIR = "logs/"
def save_conversation(session_id, history):
os.makedirs(SAVE_DIR, exist_ok=True)
with open(f"{SAVE_DIR}/{session_id}.json", "w") as f:
json.dump(history, f)
def load_conversation(session_id):
try:
with open(f"{SAVE_DIR}/{session_id}.json", "r") as f:
return json.load(f)
except FileNotFoundError:
return []