Spaces:
Build error
Build error
Commit ·
643e638
1
Parent(s): 5c64319
Update app.py
Browse filesHopefully final re-haul. Added check for environmental variable being set for OPENAI_API_KEY
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
|
|
| 1 |
import openai
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
openai.api_key = OPENAI_API_KEY
|
| 6 |
|
| 7 |
# Set up the GPT-3 model
|
| 8 |
model_engine = "gpt-3.5-turbo-0301"
|
|
@@ -24,7 +25,7 @@ def generate_response(prompt):
|
|
| 24 |
prompt=prompt,
|
| 25 |
temperature=temperature,
|
| 26 |
max_tokens=max_tokens,
|
| 27 |
-
n
|
| 28 |
stop=None,
|
| 29 |
frequency_penalty=0,
|
| 30 |
presence_penalty=0,
|
|
|
|
| 1 |
+
import os
|
| 2 |
import openai
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
# Get OpenAI API key from environment variable
|
| 6 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 7 |
|
| 8 |
# Set up the GPT-3 model
|
| 9 |
model_engine = "gpt-3.5-turbo-0301"
|
|
|
|
| 25 |
prompt=prompt,
|
| 26 |
temperature=temperature,
|
| 27 |
max_tokens=max_tokens,
|
| 28 |
+
n=1,
|
| 29 |
stop=None,
|
| 30 |
frequency_penalty=0,
|
| 31 |
presence_penalty=0,
|