arpit13 commited on
Commit
22ca223
·
verified ·
1 Parent(s): 03f3f36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -34,22 +34,21 @@ def load_history():
34
  return []
35
 
36
  # Function to save conversation history
37
- def clear_conversation_history():
38
  try:
39
  with open(CONVERSATION_FILE, "w") as file:
40
- json.dump([], file)
41
- return "Conversation history cleared successfully."
42
  except Exception as e:
43
- return f"Error clearing history: {e}"
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 [], [] # Return empty lists for chatbot and history state
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=[]):