Update app.py
Browse files
app.py
CHANGED
@@ -144,25 +144,13 @@ def comment_generate(prompt, history,post_check,full_conv,persona2, agent_name=a
|
|
144 |
do_sample=True,
|
145 |
seed=seed,
|
146 |
)
|
147 |
-
#history.append((prompt,""))
|
148 |
-
#formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
|
149 |
-
#[INST] {message} [/INST]
|
150 |
formatted_prompt = f"[INST] {system_prompt}, {prompt} [/INST]"
|
151 |
client=client_z[0]
|
152 |
-
|
153 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
154 |
-
|
155 |
output = ""
|
156 |
-
|
157 |
for response in stream:
|
158 |
output += response.token.text
|
159 |
history.append((output,None))
|
160 |
-
|
161 |
-
#comment_cnt=post_check['comment']
|
162 |
-
#print(type(comment_cnt))
|
163 |
-
#post_check['comment']=comment_cnt+1
|
164 |
-
|
165 |
-
|
166 |
|
167 |
reply_json= {'user':'','datetime':'','reply':''}
|
168 |
|
@@ -176,12 +164,6 @@ def comment_generate(prompt, history,post_check,full_conv,persona2, agent_name=a
|
|
176 |
'title':post_check['title'],'blog':1,'comment':post_check['comment']+1,'reply':post_check['reply'],
|
177 |
"prompt":post_check['prompt'],"output":post_check['output'],'comment_list':comment_out}
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
#out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
|
183 |
-
#full_conv[-1]+=(output,)
|
184 |
-
#full_conv.append((None,output,None))
|
185 |
html_out=load_html(out_json)
|
186 |
|
187 |
#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':[]}
|
@@ -261,16 +243,16 @@ def reply_generate(prompt, history,post_check,full_conv,persona1, agent_name=age
|
|
261 |
#post_check['reply']=reply_cnt+1
|
262 |
|
263 |
reply_json= {'user':persona[persona1]['name'],'datetime':current_time,'reply':output}
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
|
|
|
|
|
|
268 |
out_json = {'user':post_check['user'],'datetime':post_check['datetime'],'file_name':post_check['file_name'],
|
269 |
'title':post_check['title'],'blog':1,'comment':post_check['comment'],'reply':post_check['reply']+1,
|
270 |
-
"prompt":post_check['prompt'],"output":post_check['output'],'comment_list':post_check['comment_list']
|
271 |
-
#out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
|
272 |
-
#full_conv[-1]+=(output,)
|
273 |
-
#full_conv.append((None,output,None))
|
274 |
html_out=load_html(out_json)
|
275 |
|
276 |
#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':[]}
|
@@ -309,17 +291,15 @@ def create_valid_filename(invalid_filename: str) -> str:
|
|
309 |
|
310 |
def load_html(conv):
|
311 |
ht=""
|
312 |
-
comm=0
|
313 |
-
#for i,ea in enumerate(inp):
|
314 |
-
|
315 |
-
#blog,comm,repl=ea
|
316 |
-
#print(f'outp:: {outp}')
|
317 |
-
#print(f'prom:: {prom}')
|
318 |
ht+=f"""<div class="div_box">"""
|
319 |
-
ht+=f"""<pre class="bpost"><div class="bhead"><h2>{conv['title']}</h2><br><h5>{conv['user']}</h5
|
320 |
if conv['comment_list']:
|
321 |
for com in conv['comment_list']:
|
322 |
-
ht+=f"""<pre class="resp1"><div class="bhead"
|
|
|
|
|
|
|
|
|
323 |
for i,ea in enumerate(conv['comment_list']):
|
324 |
if conv['comment_list'][i]['reply_list']:
|
325 |
for repl in conv['comment_list'][i]['reply_list']:
|
|
|
144 |
do_sample=True,
|
145 |
seed=seed,
|
146 |
)
|
|
|
|
|
|
|
147 |
formatted_prompt = f"[INST] {system_prompt}, {prompt} [/INST]"
|
148 |
client=client_z[0]
|
|
|
149 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
|
|
150 |
output = ""
|
|
|
151 |
for response in stream:
|
152 |
output += response.token.text
|
153 |
history.append((output,None))
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
reply_json= {'user':'','datetime':'','reply':''}
|
156 |
|
|
|
164 |
'title':post_check['title'],'blog':1,'comment':post_check['comment']+1,'reply':post_check['reply'],
|
165 |
"prompt":post_check['prompt'],"output":post_check['output'],'comment_list':comment_out}
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
html_out=load_html(out_json)
|
168 |
|
169 |
#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':[]}
|
|
|
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'][0]['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':[]}
|
|
|
291 |
|
292 |
def load_html(conv):
|
293 |
ht=""
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
ht+=f"""<div class="div_box">"""
|
295 |
+
ht+=f"""<pre class="bpost"><div class="bhead"><h2>{conv['title']}</h2><br><h5>{conv['user']}</h5><br>{conv['datetime']}</div>{conv['output']}</pre>"""
|
296 |
if conv['comment_list']:
|
297 |
for com in conv['comment_list']:
|
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']:
|