Spaces:
Runtime error
Runtime error
michailroussos
commited on
Commit
·
029560f
1
Parent(s):
3dc2f1d
more
Browse files
app.py
CHANGED
@@ -33,20 +33,23 @@ def chat_with_model(user_message, chat_history=None):
|
|
33 |
).to("cuda")
|
34 |
|
35 |
# Generate response
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
streamer=
|
40 |
max_new_tokens=128,
|
41 |
use_cache=True,
|
42 |
temperature=1.5,
|
43 |
min_p=0.1,
|
44 |
)
|
45 |
|
|
|
|
|
|
|
46 |
# Append the response to the chat history
|
47 |
if chat_history is None:
|
48 |
chat_history = []
|
49 |
-
chat_history.append((user_message,
|
50 |
return "", chat_history
|
51 |
except Exception as e:
|
52 |
return f"Error: {str(e)}", chat_history
|
|
|
33 |
).to("cuda")
|
34 |
|
35 |
# Generate response
|
36 |
+
output_ids = model.generate(
|
37 |
+
input_ids=inputs["input_ids"],
|
38 |
+
attention_mask=inputs["attention_mask"], # Ensure attention_mask is included
|
39 |
+
streamer=None, # Collect output as tensor
|
40 |
max_new_tokens=128,
|
41 |
use_cache=True,
|
42 |
temperature=1.5,
|
43 |
min_p=0.1,
|
44 |
)
|
45 |
|
46 |
+
# Decode the generated tokens into a string
|
47 |
+
response = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
48 |
+
|
49 |
# Append the response to the chat history
|
50 |
if chat_history is None:
|
51 |
chat_history = []
|
52 |
+
chat_history.append((user_message, response))
|
53 |
return "", chat_history
|
54 |
except Exception as e:
|
55 |
return f"Error: {str(e)}", chat_history
|