Update app.py
Browse files
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()
|