Omnibus commited on
Commit
c6104cf
1 Parent(s): d7c04ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -22
app.py CHANGED
@@ -226,36 +226,22 @@ def reply_generate(prompt, history,post_check,full_conv,persona1,reply_to_commen
226
  do_sample=True,
227
  seed=seed,
228
  )
229
- #history.append((prompt,""))
230
- #formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
231
  formatted_prompt = f"[INST] {system_prompt}, {prompt} [/INST]"
232
  client=client_z[0]
233
-
234
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
235
-
236
  output = ""
237
-
238
  for response in stream:
239
  output += response.token.text
240
  history.append((output,None))
241
-
242
- #reply_cnt=post_check['reply']
243
- #post_check['reply']=reply_cnt+1
244
-
245
  reply_json= {'user':persona[persona1]['name'],'datetime':current_time,'reply':output}
246
-
247
- #comment_out=post_check['comment_list']
248
-
249
  post_check['comment_list'][reply_to_comment]['reply_list'].append(reply_json)
250
- #print(comment_out)
251
- #reply_out.append(reply_json)
252
- #post_check['comment_list'][0]
253
  out_json = {'user':post_check['user'],'datetime':post_check['datetime'],'file_name':post_check['file_name'],
254
  'title':post_check['title'],'blog':1,'comment':post_check['comment'],'reply':post_check['reply']+1,
255
  "prompt":post_check['prompt'],"output":post_check['output'],'comment_list':post_check['comment_list']}
 
256
  html_out=load_html(out_json)
257
 
258
- #out_json = {'user':list_of_users[0],'datetime':current_time,'file_name':filename,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output,'comment_list':[]}
259
  file_n = f'{post_check["file_name"]}.json'
260
  print(file_n)
261
 
@@ -298,12 +284,7 @@ def load_html(conv):
298
  ht+=f"""<pre class="resp1"><div class="bhead"><h5>{com['user']}</h5><br>{com['datetime']}</div>{com['comment']}</pre>"""
299
  if com['reply_list']:
300
  for repl in com['reply_list']:
301
- ht+=f"""<pre class="resp2"><div class="bhead"></div>{repl['reply']}</pre>"""
302
-
303
- for i,ea in enumerate(conv['comment_list']):
304
- if conv['comment_list'][i]['reply_list']:
305
- for repl in conv['comment_list'][i]['reply_list']:
306
- ht+=f"""<pre class="resp2"><div class="bhead"></div>{repl}</pre>"""
307
  ht+=f"""</div>"""
308
 
309
  with open('index.html','r') as h:
 
226
  do_sample=True,
227
  seed=seed,
228
  )
 
 
229
  formatted_prompt = f"[INST] {system_prompt}, {prompt} [/INST]"
230
  client=client_z[0]
 
231
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
 
232
  output = ""
 
233
  for response in stream:
234
  output += response.token.text
235
  history.append((output,None))
236
+
 
 
 
237
  reply_json= {'user':persona[persona1]['name'],'datetime':current_time,'reply':output}
 
 
 
238
  post_check['comment_list'][reply_to_comment]['reply_list'].append(reply_json)
 
 
 
239
  out_json = {'user':post_check['user'],'datetime':post_check['datetime'],'file_name':post_check['file_name'],
240
  'title':post_check['title'],'blog':1,'comment':post_check['comment'],'reply':post_check['reply']+1,
241
  "prompt":post_check['prompt'],"output":post_check['output'],'comment_list':post_check['comment_list']}
242
+
243
  html_out=load_html(out_json)
244
 
 
245
  file_n = f'{post_check["file_name"]}.json'
246
  print(file_n)
247
 
 
284
  ht+=f"""<pre class="resp1"><div class="bhead"><h5>{com['user']}</h5><br>{com['datetime']}</div>{com['comment']}</pre>"""
285
  if com['reply_list']:
286
  for repl in com['reply_list']:
287
+ ht+=f"""<pre class="resp2"><div class="bhead"><h5>{repl['user']}</h5><br>{repl['datetime']}</div>{repl['reply']}</pre>"""
 
 
 
 
 
288
  ht+=f"""</div>"""
289
 
290
  with open('index.html','r') as h: