Skip to content

Commit 661f31d

Browse files
committed
improve
1 parent 879a316 commit 661f31d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

ch05/11_qwen3/qwen3-chat-interface/qwen3-chat-interface-multiturn.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ def build_prompt_from_history(history, add_assistant_header=True):
116116
MODEL, TOKENIZER = get_model_and_tokenizer(QWEN3_CONFIG, REPO_ID, LOCAL_DIR, DEVICE, REASONING)
117117

118118
# Even though the official TOKENIZER.eos_token_id is either <|im_end|> (reasoning)
119-
# or <|endoftext|>(base), the reasoning model sometimes emits both.
120-
EOS_TOKEN_IDS = (TOKENIZER.encode("<|im_end|>"), TOKENIZER.encode("<|end_of_text|>"))
119+
# or <|endoftext|> (base), the reasoning model sometimes emits both.
120+
EOS_TOKEN_IDS = (TOKENIZER.encode("<|im_end|>")[0], TOKENIZER.encode("<|endoftext|>")[0])
121121

122122

123123
@chainlit.on_chat_start
@@ -157,8 +157,6 @@ async def main(message: chainlit.Message):
157157
if token_id in EOS_TOKEN_IDS:
158158
break
159159
piece = TOKENIZER.decode(token_id.tolist())
160-
if piece in ("<|im_end|>", "<|endoftext|>"):
161-
break
162160
await out_msg.stream_token(piece)
163161

164162
# 4) Finalize the streamed message

0 commit comments

Comments
 (0)