gr0010 commited on
Commit
d89decd
·
verified ·
1 Parent(s): 4c447a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -34,13 +34,13 @@ def generate_and_parse(messages: list, temperature: float = 0.6,
34
  and parses it into thinking and answer parts.
35
  Decorated with @spaces.GPU for Zero GPU allocation.
36
  """
37
- # Apply chat template WITHOUT enable_thinking to preserve thinking tags in history
38
- prompt_text = tokenizer.apply_chat_template(
39
- messages,
40
- tokenize=False,
41
- add_generation_prompt=True,
42
- enable_thinking=False # Changed to False to preserve <think> tags in context
43
- )
44
 
45
  # --- CONSOLE DEBUG OUTPUT ---
46
  print("\n" + "="*50)
 
34
  and parses it into thinking and answer parts.
35
  Decorated with @spaces.GPU for Zero GPU allocation.
36
  """
37
+ # Build prompt manually to preserve <think> tags in context
38
+ prompt_text = ""
39
+ for msg in messages:
40
+ role = msg["role"]
41
+ content = msg["content"]
42
+ prompt_text += f"<|im_start|>{role}\n{content}<|im_end|>\n"
43
+ prompt_text += "<|im_start|>assistant\n"
44
 
45
  # --- CONSOLE DEBUG OUTPUT ---
46
  print("\n" + "="*50)