Denver Citizen9 commited on
Commit
d0bd44c
1 Parent(s): 284a7a9

ref openai

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -1,11 +1,23 @@
1
  import gradio as gr
2
  import random
 
3
 
4
- def analyze_data(category, text):
5
- # Function implementation to analyze the data based on the selected category
6
- # Replace this with your specific logic
7
- result = f"Analyzing data for {category}: {text}"
8
- return result
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  def launch_demo():
11
  categories = [
@@ -44,7 +56,7 @@ def launch_demo():
44
  ]
45
 
46
  def analyze_input(category, text):
47
- result = analyze_data(category, text)
48
  return result
49
 
50
  dropdown = gr.components.Dropdown(categories, label="Category")
@@ -71,7 +83,7 @@ def launch_demo():
71
  outputs=output,
72
  examples=examples,
73
  title="Yo Momma's so Generative...",
74
- description="Select Category, enter Topic, and click Submit. You can also try a supplied example.",
75
  theme="default",
76
  ).launch()
77
 
 
1
  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,
14
+ max_tokens=512,
15
+ n=1,
16
+ stop=None,
17
+ temperature=0.6,
18
+ )
19
+ message = completions.choices[0].text
20
+ return message
21
 
22
  def launch_demo():
23
  categories = [
 
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")
 
83
  outputs=output,
84
  examples=examples,
85
  title="Yo Momma's so Generative...",
86
+ description="How Generative is Yo Momma? Select Category, enter Topic, and click Submit to find out. You can also try a supplied example.",
87
  theme="default",
88
  ).launch()
89