pcuenq HF staff commited on
Commit
3777798
1 Parent(s): dc2b319

Make prompt fully compliant with spec

Browse files

cc

@ysharma

,

@ArthurZ

,

@osanseviero

Files changed (1) hide show
  1. app.py +9 -4
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"<s>[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,