benhaotang commited on
Commit
69913d6
·
verified ·
1 Parent(s): 7046ce9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -46,8 +46,8 @@ def generate_response(prompt, max_length=124):
46
  print("Raw output:", outputs)
47
  # Extract just the assistant's response
48
  try:
49
- # Get the message list from the output
50
- message_list = eval(outputs[0]["generated_text"]) # Safely convert string to list
51
  # Get the last message (assistant's response)
52
  assistant_message = message_list[-1]
53
  if assistant_message["role"] == "assistant":
 
46
  print("Raw output:", outputs)
47
  # Extract just the assistant's response
48
  try:
49
+ # outputs[0]["generated_text"] is already a list of messages
50
+ message_list = outputs[0]["generated_text"]
51
  # Get the last message (assistant's response)
52
  assistant_message = message_list[-1]
53
  if assistant_message["role"] == "assistant":