nugentc commited on
Commit
5ad0ea2
·
1 Parent(s): a7fd6c1

better handle empty array

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -13,7 +13,10 @@ def chat(message, history):
13
  # append the new user input tokens to the chat history
14
  f1 = lambda x: x[2]
15
  f2 = lambda x: x[3]
16
- bot_input_ids = torch.IntTensor([f(item) for item in history for f in (f1, f2)])
 
 
 
17
  print("BOT iDS", bot_input_ids)
18
  bot_input_ids = torch.cat([bot_input_ids, new_user_input_ids], dim=-1) if bot_input_ids is not None else new_user_input_ids
19
  # generated a response while limiting the total chat history to 1000 tokens,
 
13
  # append the new user input tokens to the chat history
14
  f1 = lambda x: x[2]
15
  f2 = lambda x: x[3]
16
+ if len(history) > 0:
17
+ bot_input_ids = torch.IntTensor([f(item) for item in history for f in (f1, f2)])
18
+ else:
19
+ bot_input_id = torch.IntTensor([])
20
  print("BOT iDS", bot_input_ids)
21
  bot_input_ids = torch.cat([bot_input_ids, new_user_input_ids], dim=-1) if bot_input_ids is not None else new_user_input_ids
22
  # generated a response while limiting the total chat history to 1000 tokens,