Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,17 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|