Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,7 +43,14 @@ def chat_function(message, history):
|
|
| 43 |
|
| 44 |
messages.append({"role": "user", "content": message})
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 48 |
|
| 49 |
generation_kwargs = dict(
|
|
@@ -61,6 +68,7 @@ def chat_function(message, history):
|
|
| 61 |
partial_text += new_text
|
| 62 |
yield partial_text
|
| 63 |
|
|
|
|
| 64 |
demo = gr.ChatInterface(
|
| 65 |
fn=chat_function,
|
| 66 |
title="🤖 Cydercoder Qwen 3B AI Chatbot",
|
|
|
|
| 43 |
|
| 44 |
messages.append({"role": "user", "content": message})
|
| 45 |
|
| 46 |
+
# Fix: return_dict=False forces the tokenizer to deliver pure tensor arrays to the generation layer
|
| 47 |
+
inputs = tokenizer.apply_chat_template(
|
| 48 |
+
messages,
|
| 49 |
+
add_generation_prompt=True,
|
| 50 |
+
return_tensors="pt",
|
| 51 |
+
return_dict=False
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 55 |
|
| 56 |
generation_kwargs = dict(
|
|
|
|
| 68 |
partial_text += new_text
|
| 69 |
yield partial_text
|
| 70 |
|
| 71 |
+
|
| 72 |
demo = gr.ChatInterface(
|
| 73 |
fn=chat_function,
|
| 74 |
title="🤖 Cydercoder Qwen 3B AI Chatbot",
|