Make prompt fully compliant with spec

#48
by pcuenq HF staff - opened
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -34,12 +34,17 @@ examples=[
34
 
35
 
36
  def predict(message, chatbot):
37
-
 
38
  input_prompt = f"[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n "
39
  for interaction in chatbot:
40
- input_prompt = input_prompt + str(interaction[0]) + " [/INST] " + str(interaction[1]) + " </s><s> [INST] "
 
 
 
41
 
42
- input_prompt = input_prompt + str(message) + " [/INST] "
 
43
 
44
  data = {
45
  "inputs": input_prompt,
 
34
 
35
 
36
  def predict(message, chatbot):
37
+ # The first user message is _not_ stripped
38
+ do_strip = False
39
  input_prompt = f"[INST] <<SYS>>\n{system_message}\n<</SYS>>\n\n "
40
  for interaction in chatbot:
41
+ user_message = str(interaction[0])
42
+ user_message = user_message.strip() if do_strip else user_message
43
+ do_strip = True
44
+ input_prompt = input_prompt + user_message + " [/INST] " + str(interaction[1]).strip() + " </s><s>[INST] "
45
 
46
+ message = str(message).strip() if do_strip else str(message)
47
+ input_prompt = input_prompt + message + " [/INST]"
48
 
49
  data = {
50
  "inputs": input_prompt,