Omnibus commited on
Commit
83294e4
1 Parent(s): f42cfdd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -57
app.py CHANGED
@@ -201,7 +201,7 @@ def comment_generate(prompt, history,post_check,full_conv,persona2, agent_name=a
201
 
202
 
203
 
204
- def reply_generate(prompt, history,post_check,full_conv,persona1, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1028, top_p=0.95, repetition_penalty=1.0,):
205
  #def question_generate(prompt, history):
206
  current_time = str(datetime.datetime.now())
207
 
@@ -211,7 +211,7 @@ def reply_generate(prompt, history,post_check,full_conv,persona1, agent_name=age
211
  print(f'full_conv::\n{full_conv}')
212
  print("###############\nRUNNING REPLY GENERATOR\n###############\n")
213
  seed = random.randint(1,1111111111111111)
214
- agent=prompts.REPLY_TO_COMMENTER.format(focus=full_conv[0][0],comment=full_conv[1][1],persona=persona[persona1]['personality'])
215
  system_prompt=agent
216
  temperature = float(temperature)
217
  if temperature < 1e-2:
@@ -246,7 +246,7 @@ def reply_generate(prompt, history,post_check,full_conv,persona1, agent_name=age
246
 
247
  #comment_out=post_check['comment_list']
248
 
249
- post_check['comment_list'][0]['reply_list'].append(reply_json)
250
  #print(comment_out)
251
  #reply_out.append(reply_json)
252
  #post_check['comment_list'][0]
@@ -305,58 +305,13 @@ def load_html(conv):
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
- if inp:
310
- for i,ea in enumerate(inp):
311
-
312
- blog,comm,repl=ea
313
- #print(f'outp:: {outp}')
314
- #print(f'prom:: {prom}')
315
- ht+=f"""<div class="div_box">"""
316
- if blog:
317
- #ht+=f"""<div class="bhead"><div><h1>$btitle</h1></div><div>$user_name</div></div>"""
318
- ht+=f"""<pre class="bpost"><div class="bhead"><h2>{conv['title']}</h2><br><h5>{conv['user']}</h5></div>{blog}</pre>"""
319
- if comm:
320
- ht+=f"""<pre class="resp1"><div class="bhead"></div>{comm}</pre>"""
321
- if repl:
322
- ht+=f"""<pre class="resp2"><div class="bhead"></div>{repl}</pre>"""
323
- ht+=f"""</div>"""
324
-
325
- '''
326
- with open('index.html','r') as h:
327
- html=h.read()
328
- html = html.replace("$body",f"{ht}")
329
- #html = html.replace("$title",f"{title}")
330
- #html = html.replace("$title",f"{title}")
331
- #html = html.replace("$user_name",f"{user_name}")
332
- h.close()
333
- return html
334
-
335
- def load_html_OG(inp,title):
336
- ht=""
337
- if inp:
338
- for i,ea in enumerate(inp):
339
-
340
- outp,prom=ea
341
- #print(f'outp:: {outp}')
342
- #print(f'prom:: {prom}')
343
- if i == 0:
344
- ht+=f"""<div class="div_box">
345
- <pre class="bpost">{outp}</pre>
346
- <pre class="resp1">{prom}</pre>
347
- </div>"""
348
- else:
349
- ht+=f"""<div class="div_box">
350
- <pre class="resp2">{outp}</pre>
351
- <pre class="resp2">{prom}</pre>
352
- </div>"""
353
  with open('index.html','r') as h:
354
  html=h.read()
355
  html = html.replace("$body",f"{ht}")
356
- html = html.replace("$title",f"{title}")
357
  h.close()
358
  return html
359
-
360
 
361
 
362
 
@@ -506,12 +461,14 @@ with gr.Blocks() as app:
506
  chatbot=gr.Chatbot(visible=False)
507
  msg = gr.Textbox()
508
  with gr.Row():
509
- submit_b = gr.Button("Blog Post")
510
- submit_c = gr.Button("Comment")
511
- submit_r = gr.Button("OP Reply")
512
- with gr.Row():
513
- stop_b = gr.Button("Stop")
514
- clear = gr.ClearButton([msg, chatbot])
 
 
515
 
516
  with gr.Row():
517
  m_choice=gr.Dropdown(label="Models",type='index',choices=[c for c in models],value=models[0],interactive=True)
@@ -534,7 +491,7 @@ with gr.Blocks() as app:
534
 
535
  sub_b = submit_b.click(generate, [msg,chatbot,post_handler,chat_handler,persona1,tokens],[msg,chatbot,post_handler,chat_handler,sumbox,sum_out_box,hist_out_box,html])
536
  sub_c = submit_c.click(comment_generate, [msg,chatbot,post_handler,chat_handler,persona2],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
537
- sub_r = submit_r.click(reply_generate, [msg,chatbot,post_handler,chat_handler,persona1],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
538
  sub_e = msg.submit(generate, [msg,chatbot,post_handler,chat_handler,chat_handler,persona1,tokens],[msg,chatbot,post_handler,chat_handler,sumbox,sum_out_box,hist_out_box,html])
539
  stop_b.click(None,None,None, cancels=[sub_b,sub_e,sub_c,sub_r])
540
 
 
201
 
202
 
203
 
204
+ def reply_generate(prompt, history,post_check,full_conv,persona1,reply_to_comment, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1028, top_p=0.95, repetition_penalty=1.0,):
205
  #def question_generate(prompt, history):
206
  current_time = str(datetime.datetime.now())
207
 
 
211
  print(f'full_conv::\n{full_conv}')
212
  print("###############\nRUNNING REPLY GENERATOR\n###############\n")
213
  seed = random.randint(1,1111111111111111)
214
+ agent=prompts.REPLY_TO_COMMENTER.format(focus=post_check['output'],comment=post_check['comment_list'][reply_to_comment]['comment'],persona=persona[persona1]['personality'])
215
  system_prompt=agent
216
  temperature = float(temperature)
217
  if temperature < 1e-2:
 
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]
 
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:
310
  html=h.read()
311
  html = html.replace("$body",f"{ht}")
 
312
  h.close()
313
  return html
314
+
315
 
316
 
317
 
 
461
  chatbot=gr.Chatbot(visible=False)
462
  msg = gr.Textbox()
463
  with gr.Row():
464
+ with gr.Column(scale=2):
465
+ submit_b = gr.Button("Blog Post")
466
+ submit_c = gr.Button("Comment")
467
+ reply_num= gr.Number(label="Replying to Comment:", value=0)
468
+ submit_r = gr.Button("OP Reply")
469
+ with gr.Column(scale=1):
470
+ stop_b = gr.Button("Stop")
471
+ clear = gr.ClearButton([msg, chatbot])
472
 
473
  with gr.Row():
474
  m_choice=gr.Dropdown(label="Models",type='index',choices=[c for c in models],value=models[0],interactive=True)
 
491
 
492
  sub_b = submit_b.click(generate, [msg,chatbot,post_handler,chat_handler,persona1,tokens],[msg,chatbot,post_handler,chat_handler,sumbox,sum_out_box,hist_out_box,html])
493
  sub_c = submit_c.click(comment_generate, [msg,chatbot,post_handler,chat_handler,persona2],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
494
+ sub_r = submit_r.click(reply_generate, [msg,chatbot,post_handler,chat_handler,persona1,reply_num],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
495
  sub_e = msg.submit(generate, [msg,chatbot,post_handler,chat_handler,chat_handler,persona1,tokens],[msg,chatbot,post_handler,chat_handler,sumbox,sum_out_box,hist_out_box,html])
496
  stop_b.click(None,None,None, cancels=[sub_b,sub_e,sub_c,sub_r])
497