Omnibus commited on
Commit
a055bad
1 Parent(s): e5b450b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -103,10 +103,10 @@ def compress_history(formatted_prompt):
103
  return output
104
 
105
 
106
- def comment_generate(prompt, history,post_check, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1028, top_p=0.95, repetition_penalty=1.0,):
107
  #def question_generate(prompt, history):
108
  print(post_check)
109
- full_conv=history
110
  print(f'full_conv::\n{full_conv}')
111
  print("###############\nRUNNING QUESTION GENERATOR\n###############\n")
112
  seed = random.randint(1,1111111111111111)
@@ -206,11 +206,14 @@ def load_html(inp,title):
206
  blog,comm,repl=ea
207
  #print(f'outp:: {outp}')
208
  #print(f'prom:: {prom}')
209
- ht+=f"""<div class="div_box">
210
- <pre class="bpost">{blog}</pre>
211
- <pre class="resp1">{comm}</pre>
212
- <pre class="resp2">{repl}</pre>
213
- </div>"""
 
 
 
214
  with open('index.html','r') as h:
215
  html=h.read()
216
  html = html.replace("$body",f"{ht}")
@@ -352,7 +355,7 @@ def generate(prompt, history, post_check, agent_name=agents[0], sys_prompt="", t
352
 
353
  html_out=load_html(full_conv,title)
354
  post_check={'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0}
355
- yield prompt, history,post_check, summary[0],json_obj,json_hist,html_out
356
  else:
357
  print("passing blog")
358
 
@@ -493,6 +496,7 @@ def generate_OG(prompt, history, agent_name=agents[0], sys_prompt="", temperatur
493
 
494
 
495
  with gr.Blocks() as app:
 
496
  post_handler=gr.State()
497
  html = gr.HTML()
498
 
@@ -520,8 +524,8 @@ with gr.Blocks() as app:
520
  m_choice.change(load_models,m_choice,[chatbot])
521
  app.load(load_models,m_choice,[chatbot]).then(load_html,None,html)
522
 
523
- sub_b = submit_b.click(generate, [msg,chatbot,post_handler,tokens],[msg,chatbot,post_handler,sumbox,sum_out_box,hist_out_box,html])
524
- sub_c = submit_c.click(comment_generate, [msg,chatbot,post_handler],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
525
  sub_r = submit_r.click(reply_generate, [msg,chatbot,tokens],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
526
  sub_e = msg.submit(generate, [msg, chatbot,tokens], [msg, chatbot,sumbox,sum_out_box,hist_out_box,html])
527
  stop_b.click(None,None,None, cancels=[sub_b,sub_e,sub_c,sub_r])
 
103
  return output
104
 
105
 
106
+ def comment_generate(prompt, history,post_check,full_conv, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1028, top_p=0.95, repetition_penalty=1.0,):
107
  #def question_generate(prompt, history):
108
  print(post_check)
109
+ #full_conv=history
110
  print(f'full_conv::\n{full_conv}')
111
  print("###############\nRUNNING QUESTION GENERATOR\n###############\n")
112
  seed = random.randint(1,1111111111111111)
 
206
  blog,comm,repl=ea
207
  #print(f'outp:: {outp}')
208
  #print(f'prom:: {prom}')
209
+ ht+=f"""<div class="div_box">"""
210
+ if blog:
211
+ ht+=f"""<pre class="bpost">{blog}</pre>"""
212
+ if comm:
213
+ ht+=f"""<pre class="resp1">{comm}</pre>"""
214
+ if repl:
215
+ ht+=f"""<pre class="resp2">{repl}</pre>"""
216
+ ht+=f"""</div>"""
217
  with open('index.html','r') as h:
218
  html=h.read()
219
  html = html.replace("$body",f"{ht}")
 
355
 
356
  html_out=load_html(full_conv,title)
357
  post_check={'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0}
358
+ yield prompt, history,post_check,full_conv,summary[0],json_obj,json_hist,html_out
359
  else:
360
  print("passing blog")
361
 
 
496
 
497
 
498
  with gr.Blocks() as app:
499
+ chat_handler=gr.Stat()
500
  post_handler=gr.State()
501
  html = gr.HTML()
502
 
 
524
  m_choice.change(load_models,m_choice,[chatbot])
525
  app.load(load_models,m_choice,[chatbot]).then(load_html,None,html)
526
 
527
+ sub_b = submit_b.click(generate, [msg,chatbot,post_handler,chat_handler,tokens],[msg,chatbot,post_handler,chat_handler,sumbox,sum_out_box,hist_out_box,html])
528
+ sub_c = submit_c.click(comment_generate, [msg,chatbot,post_handler,chat_handler],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
529
  sub_r = submit_r.click(reply_generate, [msg,chatbot,tokens],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
530
  sub_e = msg.submit(generate, [msg, chatbot,tokens], [msg, chatbot,sumbox,sum_out_box,hist_out_box,html])
531
  stop_b.click(None,None,None, cancels=[sub_b,sub_e,sub_c,sub_r])