decodemai's picture
Update app.py
7c6ac3f
raw
history blame
5.89 kB
import json
import requests
import gradio as gr
import random
import time
import os
import datetime
from datetime import datetime
API_TOKEN = os.getenv("API_TOKEN")
from huggingface_hub import InferenceApi
inference = InferenceApi("bigscience/bloom",token=API_TOKEN)
prompt="""
Give 4 tech disruption ideas for a
Input:travel agency
Output:
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.
Artificial Intelligence-powered chatbot: Develop a chatbot that can handle customer inquiries, bookings, and provide personalized recommendations based on their preferences.
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.
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.
###
Input:chatbot
Output:
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.
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.
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.
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.
###
Input:biscuit brand
Output:
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.
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.
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.
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.
###
"""
def infer(prompt,
max_length = 250,
top_k = 0,
num_beams = 0,
no_repeat_ngram_size = 2,
top_p = 0.9,
seed=42,
temperature=0.7,
greedy_decoding = False,
return_full_text = False):
print(seed)
top_k = None if top_k == 0 else top_k
do_sample = False if num_beams > 0 else not greedy_decoding
num_beams = None if (greedy_decoding or num_beams == 0) else num_beams
no_repeat_ngram_size = None if num_beams is None else no_repeat_ngram_size
top_p = None if num_beams else top_p
early_stopping = None if num_beams is None else num_beams > 0
params = {
"max_new_tokens": max_length,
"top_k": top_k,
"top_p": top_p,
"temperature": temperature,
"do_sample": do_sample,
"seed": seed,
"early_stopping":early_stopping,
"no_repeat_ngram_size":no_repeat_ngram_size,
"num_beams":num_beams,
"return_full_text":return_full_text
}
s = time.time()
response = inference(prompt, params=params)
#print(response)
proc_time = time.time()-s
#print(f"Processing time was {proc_time} seconds")
return response
def getideas(text_inp):
print(text_inp)
print(datetime.today().strftime("%d-%m-%Y"))
text = prompt+"\nInput:"+text_inp + "\nOutput:"
resp = infer(text,seed=random.randint(0,100))
generated_text=resp[0]['generated_text']
result = generated_text.replace(text,'').strip()
result = result.replace("Output:","")
parts = result.split("###")
topic = parts[0].strip()
topic="\n".join(topic.split('\n')[:3])
print(topic)
return(topic)
with gr.Blocks() as demo:
gr.Markdown("<h1><center>Tech Ideas for Your Business</center></h1>")
gr.Markdown(
"""ChatGPT based Insights from <a href="https://www.decodem.ai">Decodem.ai</a> for businesses.\nWhile ChatGPT has multiple use cases we have evolved specific use cases/ templates for businesses \n\n This template provides ideas on how a business would look like in the future. Enter a business area and get the results. We use a equally powerful AI model bigscience/bloom."""
)
textbox = gr.Textbox(placeholder="Enter business type here...", lines=1,label='Your business area')
btn = gr.Button("Generate")
output1 = gr.Textbox(lines=2,label='The future')
btn.click(getideas,inputs=[textbox], outputs=[output1])
examples = gr.Examples(examples=['icecream parlor','space travel','book shop','ecommerce','grocery delivery'],
inputs=[textbox])
demo.launch()