wop commited on
Commit
0ea9587
·
verified ·
1 Parent(s): 7116955

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -21,8 +21,15 @@ def save_database(database):
21
  def format_prompt(message, system, history):
22
  # Format prompt according to the new template
23
  prompt = f"SYSTEM: {system}\n<|endofsystem|>\n"
24
- for user_prompt, bot_response in history:
25
- prompt += f"USER: {user_prompt}\n\n\nASSISTANT: {bot_response}<|endoftext|>\n"
 
 
 
 
 
 
 
26
  prompt += f"USER: {message}\n\n\nASSISTANT:"
27
  return prompt
28
 
@@ -105,4 +112,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
105
  additional_inputs=additional_inputs,
106
  )
107
 
108
- demo.queue().launch(debug=True)
 
21
  def format_prompt(message, system, history):
22
  # Format prompt according to the new template
23
  prompt = f"SYSTEM: {system}\n<|endofsystem|>\n"
24
+
25
+ for entry in history:
26
+ if len(entry) == 2: # Check if the history contains exactly two items
27
+ user_prompt, bot_response = entry
28
+ prompt += f"USER: {user_prompt}\n\n\nASSISTANT: {bot_response}<|endoftext|>\n"
29
+ else:
30
+ # If the history doesn't match the expected format, handle it gracefully
31
+ continue
32
+
33
  prompt += f"USER: {message}\n\n\nASSISTANT:"
34
  return prompt
35
 
 
112
  additional_inputs=additional_inputs,
113
  )
114
 
115
+ demo.queue().launch(debug=True)