Update app.py
Browse files
app.py
CHANGED
@@ -34,22 +34,21 @@ def load_history():
|
|
34 |
return []
|
35 |
|
36 |
# Function to save conversation history
|
37 |
-
def
|
38 |
try:
|
39 |
with open(CONVERSATION_FILE, "w") as file:
|
40 |
-
json.dump(
|
41 |
-
return "Conversation history cleared successfully."
|
42 |
except Exception as e:
|
43 |
-
|
44 |
|
45 |
# Function to clear conversation history
|
46 |
def clear_conversation_history():
|
47 |
try:
|
48 |
with open(CONVERSATION_FILE, "w") as file:
|
49 |
json.dump([], file)
|
50 |
-
return
|
51 |
except Exception as e:
|
52 |
-
return f"Error clearing history: {e}",
|
53 |
|
54 |
# Function to get response from the LLM based on category
|
55 |
def get_groq_response(message, category, history=[]):
|
|
|
34 |
return []
|
35 |
|
36 |
# Function to save conversation history
|
37 |
+
def save_history(history):
|
38 |
try:
|
39 |
with open(CONVERSATION_FILE, "w") as file:
|
40 |
+
json.dump(history, file, indent=4)
|
|
|
41 |
except Exception as e:
|
42 |
+
print(f"Error saving history: {e}")
|
43 |
|
44 |
# Function to clear conversation history
|
45 |
def clear_conversation_history():
|
46 |
try:
|
47 |
with open(CONVERSATION_FILE, "w") as file:
|
48 |
json.dump([], file)
|
49 |
+
return "Conversation history cleared successfully.", ""
|
50 |
except Exception as e:
|
51 |
+
return f"Error clearing history: {e}", ""
|
52 |
|
53 |
# Function to get response from the LLM based on category
|
54 |
def get_groq_response(message, category, history=[]):
|