rodrisouza commited on
Commit
e53f3b9
·
verified ·
1 Parent(s): e5d42bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -105,7 +105,7 @@ def interact(user_input, history, interaction_count):
105
  formatted_history = [(entry["content"], None) if entry["role"] == "user" else (None, entry["content"]) for entry in history if entry["role"] in ["user", "assistant"]]
106
  return "", formatted_history, history, interaction_count
107
  except Exception as e:
108
- if torch.cuda.is available():
109
  torch.cuda.empty_cache()
110
  print(f"Error during interaction: {e}")
111
  raise gr.Error(f"An error occurred during interaction: {str(e)}")
@@ -131,7 +131,7 @@ Here is the story:
131
  chat_history.append({"role": "system", "content": combined_message})
132
 
133
  # Generate the first question based on the story
134
- formatted_history, chat_history, interaction_count = interact("Please ask a simple question about the story to encourage interaction.", chat_history, 0)
135
 
136
  return formatted_history, chat_history, gr.update(value=[]), story["story"], interaction_count # Reset the data table and return the story
137
  else:
 
105
  formatted_history = [(entry["content"], None) if entry["role"] == "user" else (None, entry["content"]) for entry in history if entry["role"] in ["user", "assistant"]]
106
  return "", formatted_history, history, interaction_count
107
  except Exception as e:
108
+ if torch.cuda.is_available():
109
  torch.cuda.empty_cache()
110
  print(f"Error during interaction: {e}")
111
  raise gr.Error(f"An error occurred during interaction: {str(e)}")
 
131
  chat_history.append({"role": "system", "content": combined_message})
132
 
133
  # Generate the first question based on the story
134
+ _, formatted_history, chat_history, interaction_count = interact("Please ask a simple question about the story to encourage interaction.", chat_history, 0)
135
 
136
  return formatted_history, chat_history, gr.update(value=[]), story["story"], interaction_count # Reset the data table and return the story
137
  else: