Spaces:
Runtime error
Runtime error
Commit
·
15e2bf5
1
Parent(s):
453dbcd
Update app.py
Browse files
app.py
CHANGED
@@ -3,9 +3,13 @@ import gradio as gr
|
|
3 |
|
4 |
# Define the chat function
|
5 |
def chat(api_key, message):
|
|
|
|
|
|
|
|
|
6 |
# Set up the OpenAI API request
|
7 |
response = openai.Completion.create(
|
8 |
-
engine="davinci",
|
9 |
prompt=message,
|
10 |
max_tokens=1024,
|
11 |
n=1,
|
@@ -37,9 +41,5 @@ chat_button = gr.Interface(
|
|
37 |
allow_share=False,
|
38 |
)
|
39 |
|
40 |
-
#
|
41 |
-
|
42 |
-
print("Please enter your OpenAI API key and try again.")
|
43 |
-
else:
|
44 |
-
# Launch the app
|
45 |
-
chat_button.launch()
|
|
|
3 |
|
4 |
# Define the chat function
|
5 |
def chat(api_key, message):
|
6 |
+
# Check if an API key has been provided
|
7 |
+
if api_key is None:
|
8 |
+
return "Please enter your OpenAI API key and try again."
|
9 |
+
|
10 |
# Set up the OpenAI API request
|
11 |
response = openai.Completion.create(
|
12 |
+
engine="text-davinci-003",
|
13 |
prompt=message,
|
14 |
max_tokens=1024,
|
15 |
n=1,
|
|
|
41 |
allow_share=False,
|
42 |
)
|
43 |
|
44 |
+
# Launch the app
|
45 |
+
chat_button.launch()
|
|
|
|
|
|
|
|