dlflannery commited on
Commit
4ec53ca
·
verified ·
1 Parent(s): e9ba7d0

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -1,7 +1,17 @@
1
- import gradio as gr
2
-
3
- def greet(name):
4
- return "Hello " + name + "!"
5
-
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ # import openai
4
+ from openai import OpenAI
5
+
6
+
7
+ # openai.api_key = "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"
8
+ client = OpenAI(api_key="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")
9
+
10
+ def chat(prompt):
11
+ completion = client.chat.completions.create(model="gpt-3.5-turbo",
12
+ messages=[{"role":"user", "content":prompt}])
13
+ return completion.choices[0].message.content
14
+
15
+ demo = gr.Interface(fn=chat, inputs="text", outputs="text")
16
+ demo.launch()
17
+