Spaces:
Runtime error
Runtime error
File size: 3,091 Bytes
dcef704 d8d720c dcef704 d8d720c dcef704 d8d720c dcef704 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
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) |