Update app.py
Browse files
app.py
CHANGED
@@ -13,9 +13,9 @@ tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
13 |
def respond(prompt, history):
|
14 |
# 構建聊天模板
|
15 |
messages = [
|
16 |
-
{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
|
17 |
{"role": "user", "content": prompt}
|
18 |
-
]
|
19 |
text = tokenizer.apply_chat_template(
|
20 |
messages,
|
21 |
tokenize=False,
|
@@ -39,10 +39,9 @@ def respond(prompt, history):
|
|
39 |
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
40 |
]
|
41 |
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
|
|
42 |
# **去除 `<think>` 及其他無用內容**
|
43 |
response = response.replace("<think>", "").replace("</think>", "").strip()
|
44 |
-
print("Decoded response:", response)
|
45 |
-
|
46 |
# 返回回應
|
47 |
return response
|
48 |
|
|
|
13 |
def respond(prompt, history):
|
14 |
# 構建聊天模板
|
15 |
messages = [
|
16 |
+
{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant. Think internally, but do not generate thoughts explicitly in the output."},
|
17 |
{"role": "user", "content": prompt}
|
18 |
+
]
|
19 |
text = tokenizer.apply_chat_template(
|
20 |
messages,
|
21 |
tokenize=False,
|
|
|
39 |
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
40 |
]
|
41 |
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
42 |
+
print("Decoded response:", response)
|
43 |
# **去除 `<think>` 及其他無用內容**
|
44 |
response = response.replace("<think>", "").replace("</think>", "").strip()
|
|
|
|
|
45 |
# 返回回應
|
46 |
return response
|
47 |
|