File size: 2,881 Bytes
dcef704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361c653
dcef704
 
 
 
361c653
 
dcef704
 
 
6c655b6
 
 
 
 
 
7b8dc76
6c655b6
 
 
361c653
 
6c655b6
 
 
361c653
6c655b6
 
dcef704
 
 
 
6c655b6
 
 
dcef704
361c653
dcef704
 
 
6c655b6
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, audience, vision): 
    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()

with gr.Blocks() as demo:
    gr.Markdown(
    """
    # GPT3 startup pitch writer
    """
    )
    input1 = gr.Radio(["3-minute pitch", "1-minute pitch", "sentence"], label="length", value='sentence')
    input2 = gr.Text(headers=["q1"], label="What is the name of your Startup?", value='Goliath AI Consulting')
    input3 = gr.Text(headers=["q2"], label="What does your startup do?", value='We build AI Recommendation Systems')
    input4 = gr.Radio(["professional", "funny", "innovative", "challenging"], label="Tone", value='innovative')
    input5 = gr.Radio(["clients", "VCs", "social media"], label="Pitch Audience", value='VCs')
    input6 = gr.Text(headers=["q5"], label="What is the vision of your company?", value='empowering companies with the latest AI')
    
    btn = gr.Button(value="Write a Pitch!")
    state = gr.Text(label="Output")
    btn.click(greet, [input1, input2, input3, input4, input5, input6], [state])
demo.launch(share=False)

# iface = gr.Interface(
#     fn=greet,
#     title='GPT3 startup pitch writer',
#     inputs=[
#         gr.Radio(["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'),
#         
#     ],
#     outputs='text'
# )
# iface.launch(share=False)