Omnibus commited on
Commit
564d1d3
1 Parent(s): 43f0c7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -8
app.py CHANGED
@@ -21,6 +21,7 @@ summary =[]
21
  main_point=[]
22
  summary.append("")
23
  main_point.append("")
 
24
 
25
  models=[
26
  "mistralai/Mixtral-8x7B-Instruct-v0.1",
@@ -150,7 +151,7 @@ def comment_generate(prompt, history,post_check,full_conv, agent_name=agents[0],
150
  #out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
151
  #full_conv[-1]+=(output,)
152
  full_conv.append((None,output,None))
153
- html_out=load_html(full_conv,None)
154
 
155
  #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':[]}
156
  file_n = f'{post_check["filename"]}.json'
@@ -161,7 +162,8 @@ def comment_generate(prompt, history,post_check,full_conv, agent_name=agents[0],
161
  try:
162
  lod = json.loads(r.text)
163
  print(f'lod:: {lod}')
164
- lod[0]['comment_list'].append({'user':list_of_users[1],'datetime':'','comment':output})
 
165
  #hist_out.append(out_json)
166
  #try:
167
  # for ea in
@@ -179,7 +181,7 @@ def comment_generate(prompt, history,post_check,full_conv, agent_name=agents[0],
179
  )
180
  except Exception as e:
181
  print(e)
182
- return "",history,post_check,post_check,post_check,html_out
183
 
184
 
185
 
@@ -223,11 +225,36 @@ def reply_generate(prompt, history,post_check,full_conv, agent_name=agents[0], s
223
  #out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
224
  #full_conv[-1]+=(output,)
225
  full_conv.append((None,None,output))
226
- html_out=load_html(full_conv,None)
227
 
228
- #history.append((output,history))
229
- #[textbox, chatbot, textbox, json, json, html]
230
- return "",history,post_check,post_check,post_check,html_out
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
 
233
 
@@ -333,7 +360,7 @@ def load_html_OG(inp,title):
333
  return html
334
 
335
 
336
- list_of_users=["user1","user2","user3"]
337
 
338
  def generate(prompt, history, post_check,full_conv, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1048, top_p=0.95, repetition_penalty=1.0):
339
  html_out=""
 
21
  main_point=[]
22
  summary.append("")
23
  main_point.append("")
24
+ list_of_users=["user1","user2","user3"]
25
 
26
  models=[
27
  "mistralai/Mixtral-8x7B-Instruct-v0.1",
 
151
  #out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
152
  #full_conv[-1]+=(output,)
153
  full_conv.append((None,output,None))
154
+ html_out=load_html(full_conv,post_check['title'])
155
 
156
  #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':[]}
157
  file_n = f'{post_check["filename"]}.json'
 
162
  try:
163
  lod = json.loads(r.text)
164
  print(f'lod:: {lod}')
165
+ lod[0]['comment']=lod[0]['comment']+1
166
+ lod[0]['comment_list'].append({'user':list_of_users[1],'datetime':'','comment':output,'reply_list':[]})
167
  #hist_out.append(out_json)
168
  #try:
169
  # for ea in
 
181
  )
182
  except Exception as e:
183
  print(e)
184
+ return "",history,lod[0],lod[0],lod[0],html_out
185
 
186
 
187
 
 
225
  #out_json = {'user':"",'datetime':current_time,'title':title,'blog':1,'comment':0,'reply':0,"prompt":prompt,"output":output}
226
  #full_conv[-1]+=(output,)
227
  full_conv.append((None,None,output))
228
+ html_out=load_html(full_conv,post_check['title'])
229
 
230
+ file_n = f'{post_check["filename"]}.json'
231
+ print(file_n)
232
+ r = requests.get(f'{save_data}book1/{file_n}')
233
+ print(f'status code main:: {r.status_code}')
234
+ if r.status_code==200:
235
+ try:
236
+ lod = json.loads(r.text)
237
+ print(f'lod:: {lod}')
238
+ lod[0]['reply']=lod[0]['reply']+1
239
+ lod[0]['comment_list'][0]['reply_list'].append({'user':list_of_users[1],'datetime':'','reply':output})
240
+ #hist_out.append(out_json)
241
+ #try:
242
+ # for ea in
243
+ with open(f'{uid}.json', 'w') as f:
244
+ json_hist=json.dumps(lod, indent=4)
245
+ f.write(json_hist)
246
+ f.close()
247
+
248
+ upload_file(
249
+ path_or_fileobj =f"{uid}.json",
250
+ path_in_repo = f"book1/{file_n}",
251
+ repo_id =f"{username}/{dataset_name}",
252
+ repo_type = "dataset",
253
+ token=token,
254
+ )
255
+ except Exception as e:
256
+ print(e)]
257
+ return "",history,lod[0],lod[0],lod[0],html_out
258
 
259
 
260
 
 
360
  return html
361
 
362
 
363
+
364
 
365
  def generate(prompt, history, post_check,full_conv, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=1048, top_p=0.95, repetition_penalty=1.0):
366
  html_out=""