Update app.py
Browse files
app.py
CHANGED
@@ -128,7 +128,7 @@ def comment_generate(prompt, history,post_check,full_conv,persona2, agent_name=a
|
|
128 |
uid=uuid.uuid4()
|
129 |
print(post_check)
|
130 |
#full_conv=history
|
131 |
-
print(f'full_conv::\n{full_conv}')
|
132 |
print("###############\nRUNNING QUESTION GENERATOR\n###############\n")
|
133 |
seed = random.randint(1,1111111111111111)
|
134 |
#agent=prompts.COMMENTER.format(focus=main_point[0])
|
@@ -182,8 +182,8 @@ def comment_generate(prompt, history,post_check,full_conv,persona2, agent_name=a
|
|
182 |
|
183 |
#out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
|
184 |
#full_conv[-1]+=(output,)
|
185 |
-
full_conv.append((None,output,None))
|
186 |
-
html_out=load_html(
|
187 |
|
188 |
#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':[]}
|
189 |
file_n = f'{post_check["filename"]}.json'
|
@@ -269,7 +269,32 @@ def reply_generate(prompt, history,post_check,full_conv,persona1, agent_name=age
|
|
269 |
out_json = {'user':post_check['user'],'datetime':post_check['datetime'],'file_name':post_check['file_name'],
|
270 |
'title':post_check['title'],'blog':1,'comment':post_check['comment'],'reply':post_check['reply']+1,
|
271 |
"prompt":post_check['prompt'],"output":post_check['output'],'comment_list':post_check['comment_list']['reply_list'].append(reply_json)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
hist_out.append(out_json)
|
274 |
#try:
|
275 |
# for ea in
|
@@ -289,8 +314,8 @@ def reply_generate(prompt, history,post_check,full_conv,persona1, agent_name=age
|
|
289 |
|
290 |
#out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
|
291 |
#full_conv[-1]+=(output,)
|
292 |
-
full_conv.append((None,None,output))
|
293 |
-
html_out=load_html(
|
294 |
|
295 |
file_n = f'{post_check["filename"]}.json'
|
296 |
print(file_n)
|
@@ -320,7 +345,7 @@ def reply_generate(prompt, history,post_check,full_conv,persona1, agent_name=age
|
|
320 |
except Exception as e:
|
321 |
print(e)
|
322 |
return "",history,lod[0],lod[0],lod[0],html_out
|
323 |
-
|
324 |
|
325 |
|
326 |
|
@@ -341,7 +366,7 @@ def create_valid_filename(invalid_filename: str) -> str:
|
|
341 |
|
342 |
|
343 |
|
344 |
-
def load_html(
|
345 |
ht=""
|
346 |
comm=0
|
347 |
#for i,ea in enumerate(inp):
|
@@ -437,12 +462,12 @@ def generate(prompt, history, post_check,full_conv,persona1, agent_name=agents[0
|
|
437 |
sum_out=[]
|
438 |
json_hist={}
|
439 |
json_obj={}
|
440 |
-
full_conv=[]
|
441 |
post_cnt=1
|
442 |
if not post_check:
|
443 |
post_check={}
|
444 |
-
if not full_conv:
|
445 |
-
|
446 |
|
447 |
|
448 |
seed = random.randint(1,1111111111111111)
|
@@ -476,7 +501,7 @@ def generate(prompt, history, post_check,full_conv,persona1, agent_name=agents[0
|
|
476 |
prompt_out=prompt
|
477 |
for response in stream:
|
478 |
output += response.token.text
|
479 |
-
yield "", [(prompt_out,output)],post_check,
|
480 |
|
481 |
if not title:
|
482 |
for line in output.split("\n"):
|
@@ -539,10 +564,10 @@ def generate(prompt, history, post_check,full_conv,persona1, agent_name=agents[0
|
|
539 |
|
540 |
#prompt = question_generate(output, history)
|
541 |
#main_point[0]=output
|
542 |
-
full_conv.append((output,None,None))
|
543 |
|
544 |
|
545 |
-
html_out=load_html(
|
546 |
#post_check={'filename':filename,'user':persona[persona1]['name'],'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0}
|
547 |
yield prompt, history,out_json,out_json,summary[0],out_json,json_hist,html_out
|
548 |
else:
|
|
|
128 |
uid=uuid.uuid4()
|
129 |
print(post_check)
|
130 |
#full_conv=history
|
131 |
+
#print(f'full_conv::\n{full_conv}')
|
132 |
print("###############\nRUNNING QUESTION GENERATOR\n###############\n")
|
133 |
seed = random.randint(1,1111111111111111)
|
134 |
#agent=prompts.COMMENTER.format(focus=main_point[0])
|
|
|
182 |
|
183 |
#out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
|
184 |
#full_conv[-1]+=(output,)
|
185 |
+
#full_conv.append((None,output,None))
|
186 |
+
html_out=load_html(out_json)
|
187 |
|
188 |
#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':[]}
|
189 |
file_n = f'{post_check["filename"]}.json'
|
|
|
269 |
out_json = {'user':post_check['user'],'datetime':post_check['datetime'],'file_name':post_check['file_name'],
|
270 |
'title':post_check['title'],'blog':1,'comment':post_check['comment'],'reply':post_check['reply']+1,
|
271 |
"prompt":post_check['prompt'],"output":post_check['output'],'comment_list':post_check['comment_list']['reply_list'].append(reply_json)}
|
272 |
+
#out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
|
273 |
+
#full_conv[-1]+=(output,)
|
274 |
+
#full_conv.append((None,output,None))
|
275 |
+
html_out=load_html(out_json)
|
276 |
+
|
277 |
+
#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':[]}
|
278 |
+
file_n = f'{post_check["filename"]}.json'
|
279 |
+
print(file_n)
|
280 |
+
|
281 |
+
with open(f'{uid}.json', 'w') as f:
|
282 |
+
json_hist=json.dumps(out_json, indent=4)
|
283 |
+
f.write(json_hist)
|
284 |
+
f.close()
|
285 |
|
286 |
+
upload_file(
|
287 |
+
path_or_fileobj =f"{uid}.json",
|
288 |
+
path_in_repo = f"book1/{file_n}",
|
289 |
+
repo_id =f"{username}/{dataset_name}",
|
290 |
+
repo_type = "dataset",
|
291 |
+
token=token,
|
292 |
+
)
|
293 |
+
#except Exception as e:
|
294 |
+
# print(e)
|
295 |
+
return "",history,out_json,out_json,out_json,html_out
|
296 |
+
|
297 |
+
'''
|
298 |
hist_out.append(out_json)
|
299 |
#try:
|
300 |
# for ea in
|
|
|
314 |
|
315 |
#out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
|
316 |
#full_conv[-1]+=(output,)
|
317 |
+
#full_conv.append((None,None,output))
|
318 |
+
html_out=load_html(post_check)
|
319 |
|
320 |
file_n = f'{post_check["filename"]}.json'
|
321 |
print(file_n)
|
|
|
345 |
except Exception as e:
|
346 |
print(e)
|
347 |
return "",history,lod[0],lod[0],lod[0],html_out
|
348 |
+
'''
|
349 |
|
350 |
|
351 |
|
|
|
366 |
|
367 |
|
368 |
|
369 |
+
def load_html(conv):
|
370 |
ht=""
|
371 |
comm=0
|
372 |
#for i,ea in enumerate(inp):
|
|
|
462 |
sum_out=[]
|
463 |
json_hist={}
|
464 |
json_obj={}
|
465 |
+
#full_conv=[]
|
466 |
post_cnt=1
|
467 |
if not post_check:
|
468 |
post_check={}
|
469 |
+
#if not full_conv:
|
470 |
+
# full_conv=[]
|
471 |
|
472 |
|
473 |
seed = random.randint(1,1111111111111111)
|
|
|
501 |
prompt_out=prompt
|
502 |
for response in stream:
|
503 |
output += response.token.text
|
504 |
+
yield "", [(prompt_out,output)],post_check,post_check,summary[0],json_obj, json_hist,html_out
|
505 |
|
506 |
if not title:
|
507 |
for line in output.split("\n"):
|
|
|
564 |
|
565 |
#prompt = question_generate(output, history)
|
566 |
#main_point[0]=output
|
567 |
+
#full_conv.append((output,None,None))
|
568 |
|
569 |
|
570 |
+
html_out=load_html(out_json)
|
571 |
#post_check={'filename':filename,'user':persona[persona1]['name'],'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0}
|
572 |
yield prompt, history,out_json,out_json,summary[0],out_json,json_hist,html_out
|
573 |
else:
|