File size: 2,330 Bytes
2f36e59
 
d0bd44c
2f36e59
7d4f217
d0bd44c
 
 
 
7d4f217
 
 
f39b59a
d0bd44c
 
 
 
 
 
 
 
 
2f36e59
 
 
 
 
 
 
 
 
 
 
 
 
 
e6efd22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2f36e59
faf140a
 
284a7a9
2f36e59
284a7a9
9edd711
 
284a7a9
 
 
 
e6efd22
2f36e59
9edd711
284a7a9
 
2f36e59
 
 
7d4f217
7affa44
2f36e59
 
284a7a9
d0bd44c
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
import gradio as gr
import random
import openai

def tell_us_about_yo_momma(category, topic):
    openAI_key = os.getenv('my_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'

    prompt = ""
    prompt = f"Tell us a yo momma joke about her {category} and {topic}"
   
    completions = openai.Completion.create(
        engine=engine,
        prompt=prompt,
        max_tokens=512,
        n=1,
        stop=None,
        temperature=0.6,
    )
    message = completions.choices[0].text
    return message

def launch_demo():
    categories = [
        "Appearance",
        "Weight",
        "Intelligence",
        "Age",
        "Financial Status",
        "Cleanliness/Hygiene",
        "Lifestyle",
        "Occupation",
        "Taste/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's so Generative...",
        description="How Generative is Yo Momma?  Select Category, enter Topic, and click Submit to find out.  You can also try a supplied example.",
        theme="default",
    ).launch()

launch_demo()