Spaces:
Sleeping
Sleeping
Create .py
Browse files
.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio as gr
|
3 |
+
import json
|
4 |
+
|
5 |
+
openai.api_key = "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"
|
6 |
+
|
7 |
+
def main(user_messages: list):
|
8 |
+
response = openai.ChatCompletion.create(
|
9 |
+
model="gpt-3.5-turbo",
|
10 |
+
messages=user_messages
|
11 |
+
)
|
12 |
+
|
13 |
+
reply = response["choices"][0]["message"]["content"]
|
14 |
+
|
15 |
+
return reply
|
16 |
+
|
17 |
+
iface = gr.Interface(fn=main, inputs="json", outputs="text")
|
18 |
+
|
19 |
+
iface.launch()
|