ColeGuion commited on
Commit
871ce9c
·
verified ·
1 Parent(s): e9c195f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -17
app.py CHANGED
@@ -6,37 +6,26 @@ client = InferenceClient(
6
  )
7
 
8
  # Formats the prompt to hold all of the past messages
9
- """def format_prompt(message, history):
10
- prompt = "<s>"
11
-
12
- # Iterates through every pass user input and response to be added to the prompt
13
- for user_prompt, bot_response in history:
14
- prompt += f"[INST] {user_prompt} [/INST]"
15
- prompt += f" {bot_response}</s> "
16
-
17
- prompt += "[INST] Instruction [/INST] The instruction is: 'Instruction'. The answer is: Model answer</s> "
18
- #prompt += f"[INST] Please correct the grammar in the following sentence: {message} [/INST]"
19
- prompt += f"[INST] {message} [/INST]"
20
-
21
- return prompt
22
- """
23
  def format_prompt(message, history):
24
  prompt = "<s>"
25
 
26
  # String to add before every prompt
27
  prompt_prefix = "Please correct the grammar in the following sentence: "
 
28
 
29
  # Iterates through every past user input and response to be added to the prompt
30
  for user_prompt, bot_response in history:
31
  corrected_prompt = prompt_prefix + user_prompt
32
 
33
- prompt += f"[INST] {corrected_prompt} [/INST]"
 
34
  prompt += f" {bot_response}</s> "
35
  #print(f"HISTORIC PROMPT: \n\t[INST] {corrected_prompt} [/INST] {bot_response}</s> ")
36
 
37
  # Also prepend the prefix to the current message
38
- corrected_message = prompt_prefix + message
39
- prompt += f"[INST] {corrected_message} [/INST]"
 
40
  print("\nPROMPT: \n\t" + prompt)
41
 
42
  return prompt
 
6
  )
7
 
8
  # Formats the prompt to hold all of the past messages
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def format_prompt(message, history):
10
  prompt = "<s>"
11
 
12
  # String to add before every prompt
13
  prompt_prefix = "Please correct the grammar in the following sentence: "
14
+ prompt_template = "[INST] " + prompt_prefix + "{} [/INST]"
15
 
16
  # Iterates through every past user input and response to be added to the prompt
17
  for user_prompt, bot_response in history:
18
  corrected_prompt = prompt_prefix + user_prompt
19
 
20
+ #prompt += f"[INST] {corrected_prompt} [/INST]"
21
+ prompt += prompt_template.format(user_prompt)
22
  prompt += f" {bot_response}</s> "
23
  #print(f"HISTORIC PROMPT: \n\t[INST] {corrected_prompt} [/INST] {bot_response}</s> ")
24
 
25
  # Also prepend the prefix to the current message
26
+ #corrected_message = prompt_prefix + message
27
+ #prompt += f"[INST] {corrected_message} [/INST]"
28
+ prompt += prompt_template.format(message)
29
  print("\nPROMPT: \n\t" + prompt)
30
 
31
  return prompt