Spaces:
Runtime error
Runtime error
Commit
·
dc3d805
1
Parent(s):
4e6a827
Fix return values in respond function 2
Browse files
app.py
CHANGED
@@ -30,9 +30,11 @@ def chat():
|
|
30 |
# Concatenate all user inputs into a single string
|
31 |
user_input = " ".join([msg['content'] for msg in messages if msg['role'] == 'user'])
|
32 |
|
33 |
-
inputs = tokenizer
|
34 |
-
|
35 |
-
|
|
|
|
|
36 |
|
37 |
return jsonify({"response": response_text})
|
38 |
|
|
|
30 |
# Concatenate all user inputs into a single string
|
31 |
user_input = " ".join([msg['content'] for msg in messages if msg['role'] == 'user'])
|
32 |
|
33 |
+
inputs = tokenizer(user_input, return_tensors='pt', padding=True, truncation=True)
|
34 |
+
input_ids = inputs['input_ids']
|
35 |
+
attention_mask = inputs['attention_mask']
|
36 |
+
outputs = model.generate(input_ids, attention_mask=attention_mask, pad_token_id=tokenizer.eos_token_id)
|
37 |
+
response_text = tokenizer.decode(outputs[0], skip_special_tokens=True).replace(user_input, '').strip()
|
38 |
|
39 |
return jsonify({"response": response_text})
|
40 |
|