Denver Citizen9 commited on
Commit
7d4f217
1 Parent(s): d0bd44c

cleanup and openai

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -2,12 +2,14 @@ import gradio as gr
2
  import random
3
  import openai
4
 
5
- def tell_us_about_yo_momma(category, text):
6
  openAI_key = os.getenv('my_openAI_key')
7
  if openAI_key.strip()=='':
8
  return '[ERROR]: Please enter you Open AI Key. Get your key here : https://platform.openai.com/account/api-keys'
9
-
10
 
 
 
 
11
  completions = openai.Completion.create(
12
  engine=engine,
13
  prompt=prompt,
@@ -55,10 +57,6 @@ def launch_demo():
55
  "Movies/TV Shows"
56
  ]
57
 
58
- def analyze_input(category, text):
59
- result = tell_us_about_yo_momma(category, text)
60
- return result
61
-
62
  dropdown = gr.components.Dropdown(categories, label="Category")
63
  text_input = gr.components.Textbox(label="Topic")
64
  output = gr.components.Textbox(label="Lolz")
@@ -78,7 +76,7 @@ def launch_demo():
78
  ]
79
 
80
  gr.Interface(
81
- fn=analyze_input,
82
  inputs=[dropdown, text_input],
83
  outputs=output,
84
  examples=examples,
 
2
  import random
3
  import openai
4
 
5
+ def tell_us_about_yo_momma(category, topic):
6
  openAI_key = os.getenv('my_openAI_key')
7
  if openAI_key.strip()=='':
8
  return '[ERROR]: Please enter you Open AI Key. Get your key here : https://platform.openai.com/account/api-keys'
 
9
 
10
+ prompt = ""
11
+ prompt = f"Tell us a yo momma joke about her {category} and {topic}"
12
+
13
  completions = openai.Completion.create(
14
  engine=engine,
15
  prompt=prompt,
 
57
  "Movies/TV Shows"
58
  ]
59
 
 
 
 
 
60
  dropdown = gr.components.Dropdown(categories, label="Category")
61
  text_input = gr.components.Textbox(label="Topic")
62
  output = gr.components.Textbox(label="Lolz")
 
76
  ]
77
 
78
  gr.Interface(
79
+ fn=tell_us_about_yo_momma,
80
  inputs=[dropdown, text_input],
81
  outputs=output,
82
  examples=examples,