Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=
|
7 |
iface.launch()
|
|
|
1 |
+
import openai
|
2 |
+
import os
|
3 |
+
|
4 |
+
from dotenv import load_dotenv, find_dotenv
|
5 |
+
_ = load_dotenv(find_dotenv()
|
6 |
+
|
7 |
import gradio as gr
|
8 |
|
9 |
+
def get_completion(prompt, model="gpt-3.5-turbo"):
|
10 |
+
messages = [{"role": "user", "content": prompt}]
|
11 |
+
response = openai.ChatCompletion.create(
|
12 |
+
model=model,
|
13 |
+
messages=messages,
|
14 |
+
temperature=0, # this is the degree of randomness of the model's output
|
15 |
+
)
|
16 |
+
return response.choices[0].message["content"]
|
17 |
|
18 |
+
iface = gr.Interface(fn=get_completion, inputs="text", outputs="text")
|
19 |
iface.launch()
|