import requests import os gpt3_key = os.environ['GPT3_API_KEY'] def gpt3_endpoint(api_key, prompt): api_endpoint = "https://api.openai.com/v1/engines/text-davinci-003/completions" headers = { "Content-Type": "application/json", "Authorization": f"Bearer {api_key}" } data = { "prompt": prompt, "max_tokens": 200, "temperature": 0.8 } response = requests.post(api_endpoint, headers=headers, json=data) generated_text = response.json()["choices"][0]["text"] return generated_text # prompt = """ # Write a one minute pitch with innovative tone for a startup with the following info: # what does the startup do? Creating software powered with GPT3 # industry: AI # audience of the pitch: clients # vision of the startup: Empower businesses with the power of next-gen technology # """ # gpt3_endpoint(prompt) import gradio as gr #the first module becomes text1, the second module file1 def greet(length, name, do, tone): prompt = f""" Write a {length} with {tone} tone for a startup with the following info: The name of the startup: {name} what does the startup do? {do} """ # audience of the pitch: {audience} # vision of the startup: {vision} # """ return gpt3_endpoint(gpt3_key, prompt).replace('\n', ' ').strip() # iface = gr.Interface( # fn=greet, # title='GPT3 startup pitch writer', # inputs=[ # gr.Radio(["3-minute pitch", "1-minute pitch", "sentence"], label="length", value='sentence'), # gr.Text(headers=["q1"], label="What is the name of your Startup?", value="Goliath AI Consulting"), # gr.Text(headers=["q2"], label="What does your startup do?", value='Creating software powered with GPT3'), # gr.Radio(["professional", "funny", "innovative", "challenging"], label="Tone", value='innovative'), # gr.Radio(["clients", "VCs", "social media"], label="Pitch Audience", value='clients'), # gr.Text(headers=["q5"], label="What is the vision of your company?", value='Empower businesses with the power of next-gen technology') # ], # outputs='text' # ) # iface.launch(share=False) #BUG, if we try to run ONLY it on local without using share=True returns blank screen, but by sharing it it also work on localhost iface = gr.Interface( fn=greet, title='GPT3 startup pitch writer', inputs=[ gr.Radio(["3-minute pitch", "1-minute pitch", "sentence"], label="length", value='sentence'), gr.Text(headers=["q1"], label="What is the name of your Startup?", value='Goliath AI Consulting'), gr.Text(headers=["q2"], label="What does your startup do?", value='We build AI Recommendation Systems'), gr.Radio(["professional", "funny", "innovative", "challenging"], label="Tone", value='innovative'), # gr.Radio(["clients", "VCs", "social media"], label="Pitch Audience", value='VCs') # gr.Text(headers=["q5"], label="What is the vision of your company?", value='empowering companies with the latest AI') ], outputs='text' ) iface.launch(share=False)