Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ def predict(input, history=[]):
|
|
14 |
new_user_input_ids = tokenizer.encode(input + tokenizer.eos_token, return_tensors="pt")
|
15 |
|
16 |
# Append the new user input tokens to the chat history
|
17 |
-
bot_input_ids = torch.cat([torch.tensor(history), new_user_input_ids], dim=-1) if history else new_user_input_ids
|
18 |
|
19 |
# Generate a response
|
20 |
chat_history_ids = model.generate(bot_input_ids, max_length=200, pad_token_id=tokenizer.eos_token_id)
|
@@ -23,7 +23,7 @@ def predict(input, history=[]):
|
|
23 |
response = tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)
|
24 |
|
25 |
# Update the history with the new tokens
|
26 |
-
new_history = chat_history_ids.tolist()
|
27 |
|
28 |
return response, new_history
|
29 |
|
@@ -32,7 +32,7 @@ gr.Interface(
|
|
32 |
title=title,
|
33 |
description=description,
|
34 |
examples=examples,
|
35 |
-
inputs=[gr.
|
36 |
-
outputs=[gr.
|
37 |
theme="finlaymacklon/boxy_violet",
|
38 |
).launch()
|
|
|
14 |
new_user_input_ids = tokenizer.encode(input + tokenizer.eos_token, return_tensors="pt")
|
15 |
|
16 |
# Append the new user input tokens to the chat history
|
17 |
+
bot_input_ids = torch.cat([torch.tensor(history, dtype=torch.long), new_user_input_ids], dim=-1) if history else new_user_input_ids
|
18 |
|
19 |
# Generate a response
|
20 |
chat_history_ids = model.generate(bot_input_ids, max_length=200, pad_token_id=tokenizer.eos_token_id)
|
|
|
23 |
response = tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)
|
24 |
|
25 |
# Update the history with the new tokens
|
26 |
+
new_history = chat_history_ids[0].tolist()
|
27 |
|
28 |
return response, new_history
|
29 |
|
|
|
32 |
title=title,
|
33 |
description=description,
|
34 |
examples=examples,
|
35 |
+
inputs=[gr.inputs.Textbox(lines=2, placeholder="Enter your message here..."), gr.inputs.State()],
|
36 |
+
outputs=[gr.outputs.Textbox(), gr.outputs.State()],
|
37 |
theme="finlaymacklon/boxy_violet",
|
38 |
).launch()
|