openfree commited on
Commit
7b27b5d
โ€ข
1 Parent(s): 252a7fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -53,6 +53,26 @@ class ChatHistory:
53
  ])
54
  return messages
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  # ์ „์—ญ ChatHistory ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ
58
  chat_history = ChatHistory()
 
53
  ])
54
  return messages
55
 
56
+ def clear_history(self):
57
+ self.history = []
58
+ self.save_history()
59
+
60
+ def save_history(self):
61
+ try:
62
+ with open(self.history_file, 'w', encoding='utf-8') as f:
63
+ json.dump(self.history, f, ensure_ascii=False, indent=2)
64
+ except Exception as e:
65
+ print(f"ํžˆ์Šคํ† ๋ฆฌ ์ €์žฅ ์‹คํŒจ: {e}")
66
+
67
+ def load_history(self):
68
+ try:
69
+ if os.path.exists(self.history_file):
70
+ with open(self.history_file, 'r', encoding='utf-8') as f:
71
+ self.history = json.load(f)
72
+ except Exception as e:
73
+ print(f"ํžˆ์Šคํ† ๋ฆฌ ๋กœ๋“œ ์‹คํŒจ: {e}")
74
+ self.history = []
75
+
76
 
77
  # ์ „์—ญ ChatHistory ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ
78
  chat_history = ChatHistory()