djstrong commited on
Commit
78e4f96
1 Parent(s): f63805d

fix template

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -72,13 +72,16 @@ def predict(message, history, system_prompt, temperature, max_new_tokens, top_k,
72
  elif CHAT_TEMPLATE == "Bielik":
73
  stop_tokens = ["</s>"]
74
  prompt_builder = ["<s>"]
75
- for human, assistant in history:
76
- if system_prompt:
77
- prompt_builder.append(f"[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\n{human} [/INST] {assistant}</s>")
78
- system_prompt = None
79
- else:
80
- prompt_builder.append(f"[INST] {human} [/INST] {assistant}</s>")
81
- prompt_builder.append(f"[INST] {message} [/INST]")
 
 
 
82
  instruction = ''.join(prompt_builder)
83
  else:
84
  raise Exception("Incorrect chat template, select 'ChatML' or 'Mistral Instruct'")
 
72
  elif CHAT_TEMPLATE == "Bielik":
73
  stop_tokens = ["</s>"]
74
  prompt_builder = ["<s>"]
75
+ if history:
76
+ for human, assistant in history:
77
+ if system_prompt:
78
+ prompt_builder.append(f"[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\n{human} [/INST] {assistant}</s>")
79
+ system_prompt = None
80
+ else:
81
+ prompt_builder.append(f"[INST] {human} [/INST] {assistant}</s>")
82
+ prompt_builder.append(f"[INST] {message} [/INST]")
83
+ else:
84
+ prompt_builder.append(f"[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\n{message} [/INST]")
85
  instruction = ''.join(prompt_builder)
86
  else:
87
  raise Exception("Incorrect chat template, select 'ChatML' or 'Mistral Instruct'")