Omnibus commited on
Commit
da8ab41
·
verified ·
1 Parent(s): 3edcc5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -5
app.py CHANGED
@@ -6,10 +6,11 @@ import prompts
6
  import json
7
  import uuid
8
  import os
9
-
10
  token=os.environ.get("HF_TOKEN")
11
  username="omnibus"
12
  dataset_name="tmp"
 
 
13
  api=HfApi(token="")
14
  VERBOSE=False
15
 
@@ -149,8 +150,28 @@ def comment_generate(prompt, history,post_check,full_conv, agent_name=agents[0],
149
  full_conv.append((None,output,None))
150
  html_out=load_html(full_conv,None)
151
 
152
- #history.append((output,history))
153
- #[textbox, chatbot, textbox, json, json, html]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  return "",history,post_check,post_check,post_check,html_out
155
 
156
 
@@ -379,7 +400,7 @@ def generate(prompt, history, post_check,full_conv, agent_name=agents[0], sys_pr
379
  print(f'title:: {title}')
380
  filename=create_valid_filename(f'{current_time}---{title}')
381
 
382
- out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
383
 
384
  hist_out.append(out_json)
385
  #try:
@@ -425,7 +446,7 @@ def generate(prompt, history, post_check,full_conv, agent_name=agents[0], sys_pr
425
 
426
 
427
  html_out=load_html(full_conv,title,list_of_users[0])
428
- post_check={'user':list_of_users[0],'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0}
429
  yield prompt, history,post_check,full_conv,summary[0],json_obj,json_hist,html_out
430
  else:
431
  print("passing blog")
 
6
  import json
7
  import uuid
8
  import os
 
9
  token=os.environ.get("HF_TOKEN")
10
  username="omnibus"
11
  dataset_name="tmp"
12
+ save_data=f'https://huggingface.co/datasets/{username}/{dataset_name}/raw/main/'
13
+
14
  api=HfApi(token="")
15
  VERBOSE=False
16
 
 
150
  full_conv.append((None,output,None))
151
  html_out=load_html(full_conv,None)
152
 
153
+ #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':[]}
154
+ r = requests.get(f'{save_data}{post_check['filename']}')
155
+ print(f'status code main:: {r.status_code}')
156
+ if r.status_code==200:
157
+
158
+ lod = json.loads(r.text)
159
+ lod = lod['comment_list'].append({'user':list_of_users[1],'datetime':'','comment':output})
160
+ #hist_out.append(out_json)
161
+ #try:
162
+ # for ea in
163
+ with open(f'{uid}.json', 'w') as f:
164
+ json_hist=json.dumps(lod, indent=4)
165
+ f.write(json_hist)
166
+ f.close()
167
+
168
+ upload_file(
169
+ path_or_fileobj =f"{uid}.json",
170
+ path_in_repo = f"book1/{post_check['filename']}",
171
+ repo_id =f"{username}/{dataset_name}",
172
+ repo_type = "dataset",
173
+ token=token,
174
+ )
175
  return "",history,post_check,post_check,post_check,html_out
176
 
177
 
 
400
  print(f'title:: {title}')
401
  filename=create_valid_filename(f'{current_time}---{title}')
402
 
403
+ 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':[]}
404
 
405
  hist_out.append(out_json)
406
  #try:
 
446
 
447
 
448
  html_out=load_html(full_conv,title,list_of_users[0])
449
+ post_check={'filename':filename,'user':list_of_users[0],'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0}
450
  yield prompt, history,post_check,full_conv,summary[0],json_obj,json_hist,html_out
451
  else:
452
  print("passing blog")