-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
30 lines (21 loc) · 812 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
Prompt = ('You will give a tasty cooking recipe with steps '
'and explain it short. Only using the simple household ingredients '
'and given ingredient from [START] to [END].\n[START]\n ')
test_prompt = 'say this is test'
ingredients = input('ingredients you have (must seperate with comma ",") :').replace(',', '\n').encode().decode('unicode_escape')
print(ingredients)
Prompt += ingredients + '\n[END]'
print(Prompt)
response = openai.Completion.create(
model="text-curie-001",
prompt=Prompt,
max_tokens=130,
temperature=0.2
)
print(response.choices[0].text.encode().decode('unicode_escape'))
with open('response.txt', 'a') as file:
for i in list(dict(response).values()):
file.write(str(i))