FredZhang7 commited on
Commit
3dc48ef
1 Parent(s): bdbdff6

update generate_prompt

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -13,7 +13,6 @@ pipeline = PIPELINE(model, "rwkv_vocab_v20230424")
13
 
14
 
15
  def generate_prompt(instruction, input=None, history=None):
16
- has_history = (history is not None)
17
  if instruction:
18
  instruction = (
19
  instruction.strip()
@@ -21,10 +20,10 @@ def generate_prompt(instruction, input=None, history=None):
21
  .replace("\n\n", "\n")
22
  .replace("\n\n", "\n")
23
  )
24
- if has_history:
25
  input = "\""
26
  for pair in history:
27
- if len(pair[0]) > 0 and len(pair[1]) > 0:
28
  input += f"User: {pair[0]}\nAssistant: {pair[1]}\n"
29
  input = input[:-1] + "\"\n" + f"User: {instruction}"
30
  instruction = "Based on the Conversation History, generate a Response for the User."
 
13
 
14
 
15
  def generate_prompt(instruction, input=None, history=None):
 
16
  if instruction:
17
  instruction = (
18
  instruction.strip()
 
20
  .replace("\n\n", "\n")
21
  .replace("\n\n", "\n")
22
  )
23
+ if (history is not None) and len(history) > 1:
24
  input = "\""
25
  for pair in history:
26
+ if pair[0] is not None and pair[1] is not None:
27
  input += f"User: {pair[0]}\nAssistant: {pair[1]}\n"
28
  input = input[:-1] + "\"\n" + f"User: {instruction}"
29
  instruction = "Based on the Conversation History, generate a Response for the User."