bigghuggs commited on
Commit
4c87f07
·
verified ·
1 Parent(s): 1da716d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -963,7 +963,7 @@ def changeSummaryFilter(evt: gr.SelectData, seshid):
963
  return gr.Label('All', label='Merchant'), gr.Label(all_counts, label='Number of Items'), gr.Label('$'+str(np.round(all_totals, 2)), label='Total'), gr.update(visible=bool(0)), gr.update(visible=bool(1)), gr.update(visible=bool(1)), gr.update(visible=bool(0))
964
  elif summary_radio == 'Script':
965
  #textgen for general audience, things to look out for or be aware of
966
- product_pd_counts = [(product,pd_count) for store in sesh.summary_joined for product,pd_count in sesh.summary_joined[store].items()]
967
  urls = [product_pd_count[1]['product_dict']['href'] for product_pd_count in product_pd_counts]
968
  start = time.time()
969
  responses = asyncio.run(main(urls))
@@ -992,26 +992,26 @@ def changeSummaryFilter(evt: gr.SelectData, seshid):
992
 
993
  #print('indivij prep: ', items_prepped , len(items_prepped))
994
  templates = {0:['For ITEM, we went with the ITEM DESCRIPTION. SPECULATED RESPONSE.', 'SPECULATED RESPONSE, so for ITEM we went with the ITEM DESCRIPTION.'], 1:['For ITEM, we went with the ITEM DESCRIPTION. ITEM TOPIC. SPECULATED RESPONSE.', 'SPECULATED RESPONSE, so for ITEM we went with the ITEM DESCRIPTION. ITEM TOPIC.'], 2:['For ITEM, we went with the ITEM DESCRIPTION. ITEM TOPICS. SPECULATED RESPONSE.', 'SPECULATED RESPONSE, so for ITEM we went with the ITEM DESCRIPTION. ITEM TOPICS.']}
995
- responses = []
996
- for idx,data in enumerate(found_terms_4_room_items):
997
- template = templates[len(data[1]) if len(data[1])<2 else 2][np.random.choice([0,1])]
998
- prompt = items_prepped[idx]+'\n\nTEMPLATE: '+template+"\n\nTASK: adapt TEMPLATE using the ITEM/DESCRIPTION/STORE info provided, where SPECULATED RESPONSE is your creative guess as to the reader's stance on the items chosen, whether they would like the ITEM being written about and why (be creative, thinking of random reasons the reader would or would not like the ITEM chosen). Write from the perspective of reporting to someone who is considering purchasing a home and you are presenting different decorative options that might persuade them to buy the home; so, make sure your wording reflects this -- 'if you go with...', 'now keep in mind...', 'were you to purchase this home...' and the like are examples of how you might word things. You don't have to use these examples exactly, just word things similarly. Be creative."
999
- if data[1]:
1000
- prompt += " Incorporate each ITEM TOPIC in a way that is a heads up for the reader to inform them of the purchase process and what they can expect. Reference the each ITEM TOPIC in a fun way as if you are engaging in small talk, making remarks to the respective ITEM TOPIC info in a 'just a heads up' tangent and then getting back on script."
1001
- prompt += f" This should read as a review of an item chosen for a room being furnished, but the item has NOT been purchased or shipped yet. Write in an informal style. And to clarify, you are writing AS a reviewer, FOR a prospective home buyer, ABOUT an item FROM a store, and the likely buying experience with them (the store); you are writing about decorating a {sesh.room_type}. "
1002
-
1003
- if idx==0:
1004
- prompt += "Keep in mind this is the first of many items we are reviewing, so ensure your writing reflects the fact that this is just the first item being reported on."
1005
- elif idx==len(found_terms_4_room_items)-1:
1006
- prompt += "Keep in mind this is the last of many items we are reviewing, so ensure your writing reflects the fact that this is the final item being reported on and do a review wrap-up/send off for this particular room's decor review. Maybe begin by writing something along the lines of 'Okay lastly we have the...' or 'Well, our final item is...' or what have you jare examples of how you might word things. You don't have to use these examples exactly, just word things similarly. Be creative.."
1007
- else:
1008
- prompt += "Keep in mind this is one of many items we have already reviewed and one of other yet to be reviewed, so ensure your writing reflects the fact that this is just the next item being reported on. Maybe begin by writing something along the lines of 'Okay now we have...' or 'So next up is...' or what have you are examples of how you might word things. You don't have to use these examples exactly, just word things similarly. Be creative."
1009
 
1010
  #response = client.text_generation(prompt, model="mistralai/Mixtral-8x7B-Instruct-v0.1", max_new_tokens=2500)
1011
  #response = response.replace("I know what you're thinking", np.random.choice(alarm3)).replace("I know what you are thinking", np.random.choice(alarm3))
1012
  #print('script response: ', response)
1013
  #responses.append(response)
1014
- time.sleep(.7)
1015
 
1016
  #response = client.text_generation('\n\n'.join(responses)+"\n\nTASK: summarize this script for a tiktok video about a prospective homebuyer decorating this {sesh.room_type} should they purchase the home. The review should cover the following topics: { ', '.join([data[0] for idx,data in enumerate(found_terms_4_room_items)])}", model="mistralai/Mixtral-8x7B-Instruct-v0.1", max_new_tokens=2500)
1017
  #print('\n\ntiktok response: ', response)
@@ -1023,7 +1023,7 @@ def changeSummaryFilter(evt: gr.SelectData, seshid):
1023
 
1024
  #prompt = preprompt+"\n\nTask: Referencing the ITEMS provided -- each item DESCRIPTION, in particular -- create an audio script about shopping to decorate a room, writing to prompt the listener for their feedback as to whether the items chosen are choices they might have made; where applicable, incorporate the corresponding ITEM TOPICS to the item DESCRIPTION being written about, and do so in a way that is informing the listener of what they might expect during the ordering process. Reference the ITEM TOPICS in a fun way as if you are engaging in small talk, making remarks to the respective ITEM TOPIC in a 'just a heads up' tangent and then getting back on script. Write in the past tense, like we have already decorated and are now reviewing the items chosen to outfit the room, speculating as to the listener's stance on the items chosen, whether they would like the ITEM being spoken about and why (be creative, thinking of random reasons the listener would or would not like the ITEM chosen). Write in an informal style."
1025
 
1026
- end = time.time()
1027
  setSesh(seshid, sesh)
1028
  return gr.Label('All', label='Merchant'), gr.Label(all_counts, label='Number of Items'), gr.Label('$'+str(np.round(all_totals, 2)), label='Total'), gr.update(visible=bool(0)), gr.update(visible=bool(1)), gr.update(visible=bool(1)), gr.update(visible=bool(0))
1029
  else:
@@ -1121,9 +1121,9 @@ def loadColorAndCharacter(text, seshid):
1121
  sesh.product_pd_counts = [(product,pd_count) for store in sesh.summary_joined for product,pd_count in sesh.summary_joined[store].items()]
1122
  sesh.tg_responses = []
1123
  urls = [product_pd_count[1]['product_dict']['href'] for product_pd_count in sesh.product_pd_counts]
1124
- sesh.responses = asyncio.run(main(urls))
1125
 
1126
- """#gen_uid = str(time.time())
1127
  item_locator_data = {data[1]: sesh.item_data_[sesh.current_img_signature][sesh.room_type][sesh.room_style][sesh.price][sesh.Palette_ids[sesh.current_img_signature]][data[1]][data[0]] for data in sesh.display_items_[sesh.current_img_signature] if data[1] not in ['Palette', 'Living Room', 'Bedroom']}
1128
  print('item_locator_data: ', item_locator_data, '\n/*/*', [item_locator_data[product_pd_count[0]] for i,product_pd_count in enumerate(sesh.product_pd_counts)])
1129
  responses = [r.decode('ISO-8859-1') if type(r) != type(None) else r for r in sesh.responses]
 
963
  return gr.Label('All', label='Merchant'), gr.Label(all_counts, label='Number of Items'), gr.Label('$'+str(np.round(all_totals, 2)), label='Total'), gr.update(visible=bool(0)), gr.update(visible=bool(1)), gr.update(visible=bool(1)), gr.update(visible=bool(0))
964
  elif summary_radio == 'Script':
965
  #textgen for general audience, things to look out for or be aware of
966
+ """product_pd_counts = [(product,pd_count) for store in sesh.summary_joined for product,pd_count in sesh.summary_joined[store].items()]
967
  urls = [product_pd_count[1]['product_dict']['href'] for product_pd_count in product_pd_counts]
968
  start = time.time()
969
  responses = asyncio.run(main(urls))
 
992
 
993
  #print('indivij prep: ', items_prepped , len(items_prepped))
994
  templates = {0:['For ITEM, we went with the ITEM DESCRIPTION. SPECULATED RESPONSE.', 'SPECULATED RESPONSE, so for ITEM we went with the ITEM DESCRIPTION.'], 1:['For ITEM, we went with the ITEM DESCRIPTION. ITEM TOPIC. SPECULATED RESPONSE.', 'SPECULATED RESPONSE, so for ITEM we went with the ITEM DESCRIPTION. ITEM TOPIC.'], 2:['For ITEM, we went with the ITEM DESCRIPTION. ITEM TOPICS. SPECULATED RESPONSE.', 'SPECULATED RESPONSE, so for ITEM we went with the ITEM DESCRIPTION. ITEM TOPICS.']}
995
+ responses = []"""
996
+ #for idx,data in enumerate(found_terms_4_room_items):
997
+ #template = templates[len(data[1]) if len(data[1])<2 else 2][np.random.choice([0,1])]
998
+ #prompt = items_prepped[idx]+'\n\nTEMPLATE: '+template+"\n\nTASK: adapt TEMPLATE using the ITEM/DESCRIPTION/STORE info provided, where SPECULATED RESPONSE is your creative guess as to the reader's stance on the items chosen, whether they would like the ITEM being written about and why (be creative, thinking of random reasons the reader would or would not like the ITEM chosen). Write from the perspective of reporting to someone who is considering purchasing a home and you are presenting different decorative options that might persuade them to buy the home; so, make sure your wording reflects this -- 'if you go with...', 'now keep in mind...', 'were you to purchase this home...' and the like are examples of how you might word things. You don't have to use these examples exactly, just word things similarly. Be creative."
999
+ #if data[1]:
1000
+ #prompt += " Incorporate each ITEM TOPIC in a way that is a heads up for the reader to inform them of the purchase process and what they can expect. Reference the each ITEM TOPIC in a fun way as if you are engaging in small talk, making remarks to the respective ITEM TOPIC info in a 'just a heads up' tangent and then getting back on script."
1001
+ #prompt += f" This should read as a review of an item chosen for a room being furnished, but the item has NOT been purchased or shipped yet. Write in an informal style. And to clarify, you are writing AS a reviewer, FOR a prospective home buyer, ABOUT an item FROM a store, and the likely buying experience with them (the store); you are writing about decorating a {sesh.room_type}. "
1002
+
1003
+ #if idx==0:
1004
+ #prompt += "Keep in mind this is the first of many items we are reviewing, so ensure your writing reflects the fact that this is just the first item being reported on."
1005
+ #elif idx==len(found_terms_4_room_items)-1:
1006
+ #prompt += "Keep in mind this is the last of many items we are reviewing, so ensure your writing reflects the fact that this is the final item being reported on and do a review wrap-up/send off for this particular room's decor review. Maybe begin by writing something along the lines of 'Okay lastly we have the...' or 'Well, our final item is...' or what have you jare examples of how you might word things. You don't have to use these examples exactly, just word things similarly. Be creative.."
1007
+ #else:
1008
+ #prompt += "Keep in mind this is one of many items we have already reviewed and one of other yet to be reviewed, so ensure your writing reflects the fact that this is just the next item being reported on. Maybe begin by writing something along the lines of 'Okay now we have...' or 'So next up is...' or what have you are examples of how you might word things. You don't have to use these examples exactly, just word things similarly. Be creative."
1009
 
1010
  #response = client.text_generation(prompt, model="mistralai/Mixtral-8x7B-Instruct-v0.1", max_new_tokens=2500)
1011
  #response = response.replace("I know what you're thinking", np.random.choice(alarm3)).replace("I know what you are thinking", np.random.choice(alarm3))
1012
  #print('script response: ', response)
1013
  #responses.append(response)
1014
+ #time.sleep(.7)
1015
 
1016
  #response = client.text_generation('\n\n'.join(responses)+"\n\nTASK: summarize this script for a tiktok video about a prospective homebuyer decorating this {sesh.room_type} should they purchase the home. The review should cover the following topics: { ', '.join([data[0] for idx,data in enumerate(found_terms_4_room_items)])}", model="mistralai/Mixtral-8x7B-Instruct-v0.1", max_new_tokens=2500)
1017
  #print('\n\ntiktok response: ', response)
 
1023
 
1024
  #prompt = preprompt+"\n\nTask: Referencing the ITEMS provided -- each item DESCRIPTION, in particular -- create an audio script about shopping to decorate a room, writing to prompt the listener for their feedback as to whether the items chosen are choices they might have made; where applicable, incorporate the corresponding ITEM TOPICS to the item DESCRIPTION being written about, and do so in a way that is informing the listener of what they might expect during the ordering process. Reference the ITEM TOPICS in a fun way as if you are engaging in small talk, making remarks to the respective ITEM TOPIC in a 'just a heads up' tangent and then getting back on script. Write in the past tense, like we have already decorated and are now reviewing the items chosen to outfit the room, speculating as to the listener's stance on the items chosen, whether they would like the ITEM being spoken about and why (be creative, thinking of random reasons the listener would or would not like the ITEM chosen). Write in an informal style."
1025
 
1026
+ #end = time.time()
1027
  setSesh(seshid, sesh)
1028
  return gr.Label('All', label='Merchant'), gr.Label(all_counts, label='Number of Items'), gr.Label('$'+str(np.round(all_totals, 2)), label='Total'), gr.update(visible=bool(0)), gr.update(visible=bool(1)), gr.update(visible=bool(1)), gr.update(visible=bool(0))
1029
  else:
 
1121
  sesh.product_pd_counts = [(product,pd_count) for store in sesh.summary_joined for product,pd_count in sesh.summary_joined[store].items()]
1122
  sesh.tg_responses = []
1123
  urls = [product_pd_count[1]['product_dict']['href'] for product_pd_count in sesh.product_pd_counts]
1124
+ """sesh.responses = asyncio.run(main(urls))
1125
 
1126
+ #gen_uid = str(time.time())
1127
  item_locator_data = {data[1]: sesh.item_data_[sesh.current_img_signature][sesh.room_type][sesh.room_style][sesh.price][sesh.Palette_ids[sesh.current_img_signature]][data[1]][data[0]] for data in sesh.display_items_[sesh.current_img_signature] if data[1] not in ['Palette', 'Living Room', 'Bedroom']}
1128
  print('item_locator_data: ', item_locator_data, '\n/*/*', [item_locator_data[product_pd_count[0]] for i,product_pd_count in enumerate(sesh.product_pd_counts)])
1129
  responses = [r.decode('ISO-8859-1') if type(r) != type(None) else r for r in sesh.responses]