rphrp1985 commited on
Commit
4935248
·
verified ·
1 Parent(s): f427724

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -165,12 +165,24 @@ def respond(
165
  max_tokens,
166
  temperature,
167
  top_p):
 
 
 
 
 
 
 
168
 
169
  stop_tokens = ["<|endoftext|>", "<|im_end|>"]
170
- instruction = '<|im_start|>system\n' + system_message + '\n<|im_end|>\n'
171
- for user, assistant in history:
172
- instruction += f'<|im_start|>user\n{user}\n<|im_end|>\n<|im_start|>assistant\n{assistant}\n<|im_end|>\n'
173
- instruction += f'<|im_start|>user\n{message}\n<|im_end|>\n<|im_start|>assistant\n'
 
 
 
 
 
174
 
175
  print(instruction)
176
 
 
165
  max_tokens,
166
  temperature,
167
  top_p):
168
+
169
+ messages = []
170
+ json_obj = str_to_json(message)
171
+ print(json_obj)
172
+
173
+ messages= json_obj
174
+
175
 
176
  stop_tokens = ["<|endoftext|>", "<|im_end|>"]
177
+ instruction ="" #'<|im_start|>system\n' + system_message + '\n<|im_end|>\n'
178
+ for qq in messages:
179
+ role= qq['role']
180
+ content= qq['content']
181
+ instruction+= f'<|im_start|>{role}<|im_sep|>\n{content}\n<|im_end|>\n'
182
+
183
+ # for user, assistant in history:
184
+ # instruction += f'<|im_start|>user\n{user}\n<|im_end|>\n<|im_start|>assistant\n{assistant}\n<|im_end|>\n'
185
+ # instruction += f'<|im_start|>user\n{message}\n<|im_end|>\n<|im_start|>assistant\n'
186
 
187
  print(instruction)
188