abidlabs HF Staff commited on
Commit
7742db5
·
1 Parent(s): 594a418

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -20,14 +20,11 @@ def predict(input):
20
  # tokenize the new input sentence
21
  new_user_input_ids = tokenizer.encode(input + tokenizer.eos_token, return_tensors='pt')
22
 
23
- # append the new user input tokens to the chat history
24
- bot_input_ids = torch.cat([torch.LongTensor(history), new_user_input_ids], dim=-1)
25
-
26
  # generate a response
27
- history = model.generate(bot_input_ids, max_length=1000, pad_token_id=tokenizer.eos_token_id).tolist()
28
 
29
  # convert the tokens to text, and then split the responses into the right format
30
  response = tokenizer.decode(history[0]).split("<|endoftext|>")
31
  return response[1]
32
 
33
- gr.Interface(fn = predict, inputs = ["textbox"], outputs = ["text"],allow_flagging = "manual",title = title, description = description, article = article ).launch(enable_queue=True) # customizes the input component
 
20
  # tokenize the new input sentence
21
  new_user_input_ids = tokenizer.encode(input + tokenizer.eos_token, return_tensors='pt')
22
 
 
 
 
23
  # generate a response
24
+ history = model.generate(new_user_input_ids, max_length=1000, pad_token_id=tokenizer.eos_token_id).tolist()
25
 
26
  # convert the tokens to text, and then split the responses into the right format
27
  response = tokenizer.decode(history[0]).split("<|endoftext|>")
28
  return response[1]
29
 
30
+ gr.Interface(fn = predict, inputs = ["textbox"], outputs = ["text"],allow_flagging = "manual",title = title, description = description, article = article, examples=[["What are you doing?"], ["Where should we time travel to?"]] ).launch(debug=True)