Omnibus commited on
Commit
a66d7ff
1 Parent(s): 7556fb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -3
app.py CHANGED
@@ -149,7 +149,58 @@ def comment_generate(prompt, history,post_check,full_conv, agent_name=agents[0],
149
  #[textbox, chatbot, textbox, json, json, html]
150
  return "",history,post_check,post_check,post_check,html_out
151
 
152
- def reply_generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  #def question_generate(prompt, history):
154
  print("###############\nRUNNING BLOG POSTER REPLY\n###############\n")
155
  seed = random.randint(1,1111111111111111)
@@ -532,8 +583,8 @@ with gr.Blocks() as app:
532
 
533
  sub_b = submit_b.click(generate, [msg,chatbot,post_handler,chat_handler,chat_handler,tokens],[msg,chatbot,post_handler,chat_handler,sumbox,sum_out_box,hist_out_box,html])
534
  sub_c = submit_c.click(comment_generate, [msg,chatbot,post_handler,chat_handler],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
535
- sub_r = submit_r.click(reply_generate, [msg,chatbot,tokens],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
536
- sub_e = msg.submit(generate, [msg, chatbot,tokens], [msg, chatbot,sumbox,sum_out_box,hist_out_box,html])
537
  stop_b.click(None,None,None, cancels=[sub_b,sub_e,sub_c,sub_r])
538
 
539
  app.queue(default_concurrency_limit=20).launch()
 
149
  #[textbox, chatbot, textbox, json, json, html]
150
  return "",history,post_check,post_check,post_check,html_out
151
 
152
+
153
+
154
+ 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,):
155
+ #def question_generate(prompt, history):
156
+ print(post_check)
157
+ #full_conv=history
158
+ print(f'full_conv::\n{full_conv}')
159
+ print("###############\nRUNNING QUESTION GENERATOR\n###############\n")
160
+ seed = random.randint(1,1111111111111111)
161
+ agent=prompts.REPLY_TO_COMMENTER.format(focus=main_point[0])
162
+ system_prompt=agent
163
+ temperature = float(temperature)
164
+ if temperature < 1e-2:
165
+ temperature = 1e-2
166
+ top_p = float(top_p)
167
+
168
+ generate_kwargs = dict(
169
+ temperature=temperature,
170
+ max_new_tokens=max_new_tokens,
171
+ top_p=top_p,
172
+ repetition_penalty=repetition_penalty,
173
+ do_sample=True,
174
+ seed=seed,
175
+ )
176
+ #history.append((prompt,""))
177
+ formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
178
+ client=client_z[0]
179
+
180
+ stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
181
+
182
+ output = ""
183
+
184
+ for response in stream:
185
+ output += response.token.text
186
+ history.append((output,None))
187
+
188
+ comment_cnt=post_check['comment']
189
+ print(type(comment_cnt))
190
+ post_check['comment']=comment_cnt+1
191
+ #out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
192
+ #full_conv[-1]+=(output,)
193
+ full_conv.append((None,output,None))
194
+ html_out=load_html(full_conv,None)
195
+
196
+ #history.append((output,history))
197
+ #[textbox, chatbot, textbox, json, json, html]
198
+ return "",history,post_check,post_check,post_check,html_out
199
+
200
+
201
+
202
+
203
+ def reply_generate_OG(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,):
204
  #def question_generate(prompt, history):
205
  print("###############\nRUNNING BLOG POSTER REPLY\n###############\n")
206
  seed = random.randint(1,1111111111111111)
 
583
 
584
  sub_b = submit_b.click(generate, [msg,chatbot,post_handler,chat_handler,chat_handler,tokens],[msg,chatbot,post_handler,chat_handler,sumbox,sum_out_box,hist_out_box,html])
585
  sub_c = submit_c.click(comment_generate, [msg,chatbot,post_handler,chat_handler],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
586
+ sub_r = submit_r.click(reply_generate, [msg,chatbot,post_handler,chat_handler],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
587
+ sub_e = msg.submit(generate, [msg,chatbot,post_handler,chat_handler,chat_handler,tokens],[msg,chatbot,post_handler,chat_handler,sumbox,sum_out_box,hist_out_box,html])
588
  stop_b.click(None,None,None, cancels=[sub_b,sub_e,sub_c,sub_r])
589
 
590
  app.queue(default_concurrency_limit=20).launch()