Tonic commited on
Commit
4faaa57
1 Parent(s): bb02624

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -5
app.py CHANGED
@@ -34,18 +34,14 @@ class ChatBot:
34
  user_input_ids = tokenizer.encode(input + tokenizer.eos_token, return_tensors="pt")
35
 
36
  # Concatenate the user input with chat history
37
- if self.history:
38
  chat_history_ids = torch.cat([self.history, user_input_ids], dim=-1)
39
  else:
40
  chat_history_ids = user_input_ids
41
 
42
  # Generate a response using the PEFT model
43
- # response = peft_model.generate(chat_history_ids, max_length=512, pad_token_id=tokenizer.eos_token_id)
44
- # response = peft_model.generate(chat_history_ids)
45
  response = peft_model.generate(input_ids=chat_history_ids, max_length=512, pad_token_id=tokenizer.eos_token_id)
46
 
47
-
48
-
49
  # Update chat history
50
  self.history = chat_history_ids
51
 
 
34
  user_input_ids = tokenizer.encode(input + tokenizer.eos_token, return_tensors="pt")
35
 
36
  # Concatenate the user input with chat history
37
+ if self.history.numel() > 0:
38
  chat_history_ids = torch.cat([self.history, user_input_ids], dim=-1)
39
  else:
40
  chat_history_ids = user_input_ids
41
 
42
  # Generate a response using the PEFT model
 
 
43
  response = peft_model.generate(input_ids=chat_history_ids, max_length=512, pad_token_id=tokenizer.eos_token_id)
44
 
 
 
45
  # Update chat history
46
  self.history = chat_history_ids
47