meraj12 commited on
Commit
615751f
·
verified ·
1 Parent(s): 21d669f

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +10 -3
utils.py CHANGED
@@ -57,7 +57,14 @@ def list_chat_histories():
57
 
58
  def load_chat_history(filename):
59
  """
60
- Load a specific chat history file.
61
  """
62
- with open(os.path.join("history", filename), "r") as f:
63
- return json.load(f)
 
 
 
 
 
 
 
 
57
 
58
  def load_chat_history(filename):
59
  """
60
+ Load a specific chat history file with None check.
61
  """
62
+ if not filename:
63
+ st.warning("No file selected to load history.")
64
+ return []
65
+ try:
66
+ with open(os.path.join("history", filename), "r") as f:
67
+ return json.load(f)
68
+ except FileNotFoundError:
69
+ st.warning("Selected history file not found.")
70
+ return []