File size: 2,539 Bytes
2f36e59
 
d0bd44c
1e94fd4
2f36e59
7d4f217
58b2a2f
d0bd44c
 
6fd8c38
d0bd44c
7d4f217
64f2548
7d4f217
842f3be
 
d0bd44c
 
 
 
2fe1401
d0bd44c
69e0733
d0bd44c
2f36e59
 
 
 
 
 
 
 
3c61c6b
74df4ec
3c61c6b
2f36e59
 
95f0d5d
 
2f36e59
e6efd22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f36e59
faf140a
 
284a7a9
2f36e59
284a7a9
9edd711
 
284a7a9
 
 
 
e6efd22
2f36e59
9edd711
284a7a9
 
2f36e59
 
 
7d4f217
7affa44
2f36e59
 
95f0d5d
74df4ec
2f36e59
 
 
db3fa21
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import gradio as gr
import random
import openai
import os

def tell_us_about_yo_momma(category, topic):
    openAI_key = os.getenv('openAI_key')
    if openAI_key.strip()=='':
        return '[ERROR]: Please enter you Open AI Key. Get your key here : https://platform.openai.com/account/api-keys'
    openai.api_key = openAI_key

    prompt = ""
    prompt = f"You are a comedian who is bold, cutting, and broadly appealing.  Tell us a yo momma joke about her {category} that is at least loosely related to: {topic}."
   
    completions = openai.Completion.create(
        model="text-davinci-003",
        prompt=prompt,
        max_tokens=512,
        n=1,
        stop=None,
        temperature=0.7,
    )
    message = completions.choices[0].text.strip()
    return message

def launch_demo():
    categories = [
        "Appearance",
        "Weight",
        "Intelligence",
        "Age",
        "Financial Status",
        "Cleanliness",
        "Dirtyness",
        "Hygiene",
        "Lifestyle",
        "Occupation",
        "Culture",
        "Cooking Skills"
    ]
    
    
    topics = [
        "Holidays",
        "Plants",
        "Animals",
        "Countries",
        "Pop Culture",
        "Religion",
        "Lifestyle",
        "Environment",
        "Technology",
        "Sports",
        "Music",
        "Space/Astronomy",
        "Food and Cooking",
        "History",
        "Travel",
        "Education",
        "Health and Fitness",
        "Movies/TV Shows"
    ]

    dropdown = gr.components.Dropdown(categories, label="Category")
    text_input = gr.components.Textbox(label="Topic")
    output = gr.components.Textbox(label="Lolz")

    # some random pre-seeded options
    rando_choice = random.choice(categories)
    rando_topic = random.choice(topics)
    rando_choice_b = random.choice(categories)
    rando_topic_b = random.choice(topics)
    rando_choice_c = random.choice(categories)
    rando_topic_c = random.choice(topics)

    examples = [
        [rando_choice, rando_topic],
        [rando_choice_b, rando_topic_b],
        [rando_choice_c, rando_topic_c],
    ]

    gr.Interface(
        fn=tell_us_about_yo_momma,
        inputs=[dropdown, text_input],
        outputs=output,
        examples=examples,
        title="Yo Momma so Generative...",
        description="Select a Category, enter a Topic, and click Submit to find out how generative Yo Momma is.<br><br>You can also try selecting one of the supplied examples.",
        theme="default",
    ).launch()

launch_demo()