Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,21 @@
|
|
| 1 |
import pickle
|
| 2 |
import openai
|
| 3 |
-
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
# with open("apikey.pkl", "rb") as f:
|
| 7 |
# apikey = pickle.load(f)
|
| 8 |
# print(apikey)
|
| 9 |
|
|
|
|
| 10 |
def get_open_ai_output(recipe_titles):
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
response = openai.Completion.create(
|
| 15 |
-
model="text-davinci-003",
|
| 16 |
-
prompt=generate_prompt(recipe_titles),
|
| 17 |
temperature=0.98,
|
| 18 |
max_tokens = 4000
|
| 19 |
)
|
| 20 |
-
|
| 21 |
return response
|
| 22 |
|
| 23 |
|
|
|
|
| 1 |
import pickle
|
| 2 |
import openai
|
| 3 |
+
import os
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
# with open("apikey.pkl", "rb") as f:
|
| 7 |
# apikey = pickle.load(f)
|
| 8 |
# print(apikey)
|
| 9 |
|
| 10 |
+
os.getenv(OPENAI_API_KEY)
|
| 11 |
def get_open_ai_output(recipe_titles):
|
| 12 |
+
response = openai.Completion.create(
|
| 13 |
+
model="text-davinci-003",
|
| 14 |
+
prompt=generate_prompt(recipe_titles),
|
|
|
|
|
|
|
|
|
|
| 15 |
temperature=0.98,
|
| 16 |
max_tokens = 4000
|
| 17 |
)
|
| 18 |
+
response = response.choices[0].text
|
| 19 |
return response
|
| 20 |
|
| 21 |
|