Spaces:
Sleeping
Sleeping
File size: 963 Bytes
97b42fd | 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 27 28 29 30 | import json
async def load_history(redis_client , session_id) :
# ! ----------------------------only for dev----------------------------
with open('assets/history/chat.json') as chat_file : history = json.load(chat_file)
if session_id in history : return history[session_id]
else : return []
# ! --------------------------------------------------------
# messages = redis_client.get(session_id)
# if messages : return json.loads(messages)
# return []
async def save_history(redis_client , row , session_id) :
# ! ----------------------------only for Dev----------------------------
with open('assets/history/chat.json') as chat_file : history = json.load(chat_file)
history[session_id] = row
with open('assets/history/chat.json' , 'w') as chat_file : json.dump(history , chat_file)
# ! --------------------------------------------------------
# redis_client.set(session_id , json.dumps(row)) |