pvanand commited on
Commit
890b409
1 Parent(s): 11182eb

Fix bot response from openai

Browse files

Handle json with multiple elements

Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -31,7 +31,12 @@ if user_input := st.chat_input("What is up?"):
31
 
32
  # Extract assistant response
33
  if bot_reply !=[]:
34
- assistant_response = bot_reply[0]["text"]
 
 
 
 
 
35
  else:
36
  assistant_response = 'API request returned with an empty list []. Please continue with a different question'
37
 
 
31
 
32
  # Extract assistant response
33
  if bot_reply !=[]:
34
+ assistant_response = ""
35
+ if len(bot_reply)>1:
36
+ for reply in bot_reply[1:]:
37
+ assistant_response+=(" "+reply['text'])
38
+ else:
39
+ assistant_response = bot_reply[0]['text']
40
  else:
41
  assistant_response = 'API request returned with an empty list []. Please continue with a different question'
42