Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py (#2)
Browse files- Upload app.py (2011daf1337c19c09423a3b163cae1ba24db559c)
Co-authored-by: Longguang Zhong <[email protected]>
app.py
CHANGED
@@ -48,7 +48,7 @@ def generate(
|
|
48 |
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
49 |
conversation.append({"role": "user", "content": message})
|
50 |
|
51 |
-
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
|
52 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
53 |
input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
|
54 |
gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
|
@@ -130,4 +130,4 @@ with gr.Blocks(css="style.css") as demo:
|
|
130 |
chat_interface.render()
|
131 |
|
132 |
if __name__ == "__main__":
|
133 |
-
demo.queue(max_size=20).launch()
|
|
|
48 |
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
49 |
conversation.append({"role": "user", "content": message})
|
50 |
|
51 |
+
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt", add_generation_prompt=True)
|
52 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
53 |
input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
|
54 |
gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")
|
|
|
130 |
chat_interface.render()
|
131 |
|
132 |
if __name__ == "__main__":
|
133 |
+
demo.queue(max_size=20).launch()
|