ajsbsd commited on
Commit
23078b2
·
verified ·
1 Parent(s): 8993bb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -105,13 +105,14 @@ def predict_chat(message: str, history: list):
105
  generated_text += token
106
  yield generated_text
107
 
108
- else:
109
  input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
110
  inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
111
 
112
  outputs = model.generate(
113
  inputs,
114
- max_new_tokens=MAX_NEW_TOKENS,
 
115
  temperature=TEMPERATURE,
116
  top_k=TOP_K,
117
  top_p=TOP_P,
@@ -157,7 +158,7 @@ if __name__ == "__main__":
157
  ["What's the best way to stay motivated?"],
158
  ],
159
  cache_examples=False,
160
- # REMOVED: clear_btn="Clear Chat"
161
  )
162
 
163
  demo.chatbot.value = initial_messages_for_value
 
105
  generated_text += token
106
  yield generated_text
107
 
108
+ else: # This is the block where the error occurred
109
  input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
110
  inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
111
 
112
  outputs = model.generate(
113
  inputs,
114
+ # Changed max_new_tokens to max_length for broader compatibility
115
+ max_length=inputs.shape[-1] + MAX_NEW_TOKENS,
116
  temperature=TEMPERATURE,
117
  top_k=TOP_K,
118
  top_p=TOP_P,
 
158
  ["What's the best way to stay motivated?"],
159
  ],
160
  cache_examples=False,
161
+ # clear_btn="Clear Chat" was removed in the previous step
162
  )
163
 
164
  demo.chatbot.value = initial_messages_for_value