decodemai commited on
Commit
81cac81
1 Parent(s): fc0a441

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -11
app.py CHANGED
@@ -3,28 +3,88 @@ import requests
3
  import gradio as gr
4
  import random
5
 
6
- API_TOKEN='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'
7
- headers = {"Authorization": f"Bearer {API_TOKEN}"}
8
- API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
9
-
10
  from huggingface_hub import InferenceApi
11
  API_TOKEN='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'
12
 
13
  inference = InferenceApi("bigscience/bloom",token=API_TOKEN)
14
 
15
- prompt="""What would this look like in 2050? Give 5 optimally describing bigrams.
16
- Input:cake shop
17
- Output:Sustainable ingredients,Virtual reality experience,Customizable flavor options,3D printed designs,Robotic assistants
 
 
 
 
 
18
  #####
19
- Input:consulting firm
20
- Output:Virtual meetings,AI integration,Sustainability focus,Virtual reality simulations,Blockchain technology
 
 
 
 
21
  #####
22
  Input:biscuit brand
23
- Output:Sustainable packaging,Plant-based ingredients,Digital marketing,Virtual reality,Smart packaging
 
 
 
 
24
  #####
25
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
 
 
27
 
 
 
 
 
 
 
 
 
28
  def query(text):
29
  #global prompt
30
  print(text)
@@ -61,7 +121,7 @@ with gr.Blocks() as demo:
61
  btn = gr.Button("Generate")
62
  output1 = gr.Textbox(lines=2,label='The future')
63
 
64
- btn.click(query,inputs=[textbox], outputs=[output1])
65
  examples = gr.Examples(examples=['icecream parlor','space travel','book shop','ecommerce','grocery delivery'],
66
  inputs=[textbox])
67
 
 
3
  import gradio as gr
4
  import random
5
 
 
 
 
 
6
  from huggingface_hub import InferenceApi
7
  API_TOKEN='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'
8
 
9
  inference = InferenceApi("bigscience/bloom",token=API_TOKEN)
10
 
11
+ prompt="""
12
+ Give 4 tech disruption ideas for a
13
+ Input: travel agency
14
+ Output:
15
+ Virtual Reality:Create virtual tours for customers to explore destinations before booking a trip, allowing them to experience the location in a more immersive way.
16
+ Artificial Intelligence-powered chatbot: Develop a chatbot that can handle customer inquiries, bookings, and provide personalized recommendations based on their preferences.
17
+ Blockchain-based loyalty program: Implement a blockchain-based loyalty program that rewards customers for booking with the agency and can be used at participating hotels, restaurants, and other travel-related businesses.
18
+ Social media integration: Utilize social media platforms such as Instagram and Facebook to showcase user-generated content, such as photos and reviews, in order to attract new customers and build trust with potential clients.
19
  #####
20
+ Input:chatbot
21
+ Output:
22
+ Personalized shopping assistant: A chatbot that can assist customers in finding and purchasing products based on their preferences and previous purchase history. This chatbot could also recommend similar products and provide information about sales and promotions.
23
+ Virtual health coach: A chatbot that can assist users in tracking their fitness and health goals, providing personalized workout and nutrition plans, and answering any health-related questions they may have.
24
+ Smart home integration: A chatbot that can integrate with smart home devices, allowing users to control their lights, thermostat, and other devices through voice commands or text messages.
25
+ Educational tutor: A chatbot that can assist students in their studies by providing explanations of difficult concepts, practice quizzes, and personalized study plans. This chatbot could also assist students in scheduling and organizing their assignments and exams.
26
  #####
27
  Input:biscuit brand
28
+ Output:
29
+ Virtual reality cookie tasting experiences: Use virtual reality technology to create an immersive experience for customers where they can taste and interact with different biscuit flavors and varieties. This could be used in-store or online as a marketing tool to promote new products or limited edition flavors.
30
+ Smart packaging: Use smart packaging technology to create interactive packaging that provides nutritional information, recipes, and other information about the product. This could also include a QR code that customers can scan to access additional information or enter a contest.
31
+ AI-powered cookie customization: Use artificial intelligence technology to create a customization tool that allows customers to create their own unique biscuit flavor and design. This could include options such as choosing different flavors, shapes, and decorations.
32
+ Home delivery robots: Use autonomous delivery robots to deliver biscuits directly to customers' homes. This could be a convenient way for customers to receive their favorite biscuits without having to leave the house. The robots could also be used to deliver other household essentials.
33
  #####
34
  """
35
+
36
+ def infer(prompt,
37
+ max_length = 250,
38
+ top_k = 0,
39
+ num_beams = 0,
40
+ no_repeat_ngram_size = 2,
41
+ top_p = 0.9,
42
+ seed=42,
43
+ temperature=0.7,
44
+ greedy_decoding = False,
45
+ return_full_text = False):
46
+
47
+ print(seed)
48
+ top_k = None if top_k == 0 else top_k
49
+ do_sample = False if num_beams > 0 else not greedy_decoding
50
+ num_beams = None if (greedy_decoding or num_beams == 0) else num_beams
51
+ no_repeat_ngram_size = None if num_beams is None else no_repeat_ngram_size
52
+ top_p = None if num_beams else top_p
53
+ early_stopping = None if num_beams is None else num_beams > 0
54
+
55
+ params = {
56
+ "max_new_tokens": max_length,
57
+ "top_k": top_k,
58
+ "top_p": top_p,
59
+ "temperature": temperature,
60
+ "do_sample": do_sample,
61
+ "seed": seed,
62
+ "early_stopping":early_stopping,
63
+ "no_repeat_ngram_size":no_repeat_ngram_size,
64
+ "num_beams":num_beams,
65
+ "return_full_text":return_full_text
66
+ }
67
+
68
+ s = time.time()
69
+ response = inference(prompt, params=params)
70
+ #print(response)
71
+ proc_time = time.time()-s
72
+ #print(f"Processing time was {proc_time} seconds")
73
+ return response
74
+
75
+ def getideas(text_inp):
76
 
77
+ prompt += "Input:"+text_inp + "\nOutput:"
78
+ resp = infer(prompt,seed=random.randint(0,100))
79
 
80
+ generated_text=resp[0]['generated_text']
81
+ result = generated_text.replace(prompt,'').strip()
82
+ result = result.replace("Output:","")
83
+ parts = result.split("###")
84
+ topic = parts[0].strip()
85
+ topic="\n".join(topic.split('\n')[:3])
86
+ return(topic)
87
+
88
  def query(text):
89
  #global prompt
90
  print(text)
 
121
  btn = gr.Button("Generate")
122
  output1 = gr.Textbox(lines=2,label='The future')
123
 
124
+ btn.click(getideas,inputs=[textbox], outputs=[output1])
125
  examples = gr.Examples(examples=['icecream parlor','space travel','book shop','ecommerce','grocery delivery'],
126
  inputs=[textbox])
127