bigghuggs commited on
Commit
b50db34
·
verified ·
1 Parent(s): 2280f6d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1255,7 +1255,7 @@ def searchColorAndCharacter(text, seshid):
1255
  pass"""
1256
 
1257
 
1258
- start = time.time()
1259
  urls = ['https://dreamdemo.pythonanywhere.com/script_gen' for _ in range(len(sesh.product_pd_counts))]
1260
  headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
1261
  json_data = [json.dumps({'room_type': sesh.room_type, 'idx': i, 'gen_uid': sesh.gen_uid}) for i in range(len(sesh.product_pd_counts))]
@@ -1266,7 +1266,7 @@ def searchColorAndCharacter(text, seshid):
1266
  #sesh.tg_responses = [json.loads(r)['response'] if type(r) == type(b'') else '********' for r in responses]
1267
  #sesh.tg_responses.append(tg_response)
1268
  print('searchColorAndCharacter script_gen: ', (end-start)/60, [(r[:250], sesh.product_pd_counts[i][0]) for i,r in enumerate(sesh.tg_responses)])
1269
-
1270
  """script_prompts = {'Youtube Long-Form': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for a long-form Youtube video. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.', 'Youtube Short-Form': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for a Youtube Short. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.', 'Facebook Long-Form': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for a long-form Facebook video. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.', 'Instagram Reel': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for an Instagram Reel video. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.', 'Tiktok': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for a Tiktok video. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.', 'LinkedIn': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for a LinkedIn long-form video. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.'}
1271
  start = time.time()
1272
  script_types = [s for s in script_prompts]
@@ -1281,8 +1281,8 @@ def searchColorAndCharacter(text, seshid):
1281
 
1282
  #sesh.found_terms_4_room_items = [(sesh.product_pd_counts[ir][0], findShoppingRelevantTerms(r)) for ir,r in enumerate(sesh.responses)]
1283
  #print('searchColorAndCharacter 2: ', sesh.found_terms_4_room_items)
1284
- sesh.found_terms_4_room_items_idx = 0
1285
- sesh.scripts = {}
1286
  #sesh.items_prepped = ['\n\n'.join([f'ITEM: {data[0].upper()}\n\n'+f'{data[0].upper()} STORE: '+sesh.product_pd_counts[idx][1]['product_dict']['store']+'\n\n'+f'{data[0].upper()} DESCRIPTION: '+sesh.product_pd_counts[idx][1]['product_dict']['description']+'\n\n'+'\n\n'.join([f'{data[0].upper()} TOPIC: '+(term[1:-1].upper() if term[1:-1] != 'ship' else 'SHIPPING')+'\n...'+text for term,text in data[1].items()])]) for idx,data in enumerate(sesh.found_terms_4_room_items)]
1287
  #item_prompts = [makeItemPrompt(idx,idata) for idx,idata in enumerate(sesh.found_terms_4_room_items[sesh.found_terms_4_room_items_idx])]
1288
  #item_scripts = multiprocessPrompts(item_prompts)
@@ -1779,9 +1779,10 @@ def selectScript(evt: gr.SelectData, seshid):
1779
  #valid_data = {'item_locator_data': item_locator_data}
1780
  valid_data = {'seshid':seshid, 'genuid': sesh.frmt_id_maps[sesh.current_img_signature][format]}
1781
  headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
 
1782
  r = requests.post(url, data=json.dumps(valid_data), headers=headers)
1783
  jsondata = json.loads(r.content)
1784
- print('selectScript: ', format, jsondata)
1785
  #return sesh.scripts[script]
1786
  return 'sesh.scripts[script]'
1787
 
 
1255
  pass"""
1256
 
1257
 
1258
+ """start = time.time()
1259
  urls = ['https://dreamdemo.pythonanywhere.com/script_gen' for _ in range(len(sesh.product_pd_counts))]
1260
  headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i,_ in enumerate(urls)]
1261
  json_data = [json.dumps({'room_type': sesh.room_type, 'idx': i, 'gen_uid': sesh.gen_uid}) for i in range(len(sesh.product_pd_counts))]
 
1266
  #sesh.tg_responses = [json.loads(r)['response'] if type(r) == type(b'') else '********' for r in responses]
1267
  #sesh.tg_responses.append(tg_response)
1268
  print('searchColorAndCharacter script_gen: ', (end-start)/60, [(r[:250], sesh.product_pd_counts[i][0]) for i,r in enumerate(sesh.tg_responses)])
1269
+ """
1270
  """script_prompts = {'Youtube Long-Form': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for a long-form Youtube video. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.', 'Youtube Short-Form': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for a Youtube Short. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.', 'Facebook Long-Form': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for a long-form Facebook video. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.', 'Instagram Reel': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for an Instagram Reel video. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.', 'Tiktok': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for a Tiktok video. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.', 'LinkedIn': 'SCRIPT: \n\n'+'\n\n'.join(sesh.tg_responses)+f'\n\nTASK: rewrite the provided SCRIPT for a LinkedIn long-form video. Keep in mind the SCRIPT is about reviewing items to potentially have purchased, shipped and decorate a {sesh.room_type}; this is all for a prospective home buyer -- you are the item reviewer who is reviewing items on behalf of the potential home buyer.'}
1271
  start = time.time()
1272
  script_types = [s for s in script_prompts]
 
1281
 
1282
  #sesh.found_terms_4_room_items = [(sesh.product_pd_counts[ir][0], findShoppingRelevantTerms(r)) for ir,r in enumerate(sesh.responses)]
1283
  #print('searchColorAndCharacter 2: ', sesh.found_terms_4_room_items)
1284
+ #sesh.found_terms_4_room_items_idx = 0
1285
+ #sesh.scripts = {}
1286
  #sesh.items_prepped = ['\n\n'.join([f'ITEM: {data[0].upper()}\n\n'+f'{data[0].upper()} STORE: '+sesh.product_pd_counts[idx][1]['product_dict']['store']+'\n\n'+f'{data[0].upper()} DESCRIPTION: '+sesh.product_pd_counts[idx][1]['product_dict']['description']+'\n\n'+'\n\n'.join([f'{data[0].upper()} TOPIC: '+(term[1:-1].upper() if term[1:-1] != 'ship' else 'SHIPPING')+'\n...'+text for term,text in data[1].items()])]) for idx,data in enumerate(sesh.found_terms_4_room_items)]
1287
  #item_prompts = [makeItemPrompt(idx,idata) for idx,idata in enumerate(sesh.found_terms_4_room_items[sesh.found_terms_4_room_items_idx])]
1288
  #item_scripts = multiprocessPrompts(item_prompts)
 
1779
  #valid_data = {'item_locator_data': item_locator_data}
1780
  valid_data = {'seshid':seshid, 'genuid': sesh.frmt_id_maps[sesh.current_img_signature][format]}
1781
  headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
1782
+ start = time.time()
1783
  r = requests.post(url, data=json.dumps(valid_data), headers=headers)
1784
  jsondata = json.loads(r.content)
1785
+ print('selectScript: ', format, time.time()-start, jsondata)
1786
  #return sesh.scripts[script]
1787
  return 'sesh.scripts[script]'
1788