Cydercoder commited on
Commit
54d2961
·
verified ·
1 Parent(s): 185d525

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -43,7 +43,14 @@ def chat_function(message, history):
43
 
44
  messages.append({"role": "user", "content": message})
45
 
46
- inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
 
 
 
 
 
 
 
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",