generated from Prasanna28Devadiga/Best-README-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.py
47 lines (41 loc) · 1.26 KB
/
script.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import openai
import random
openai.api_key = OPENAI_API_KEY='Insert your key here'
# list engines
engines = openai.Engine.list()
string1= ""
list_prompts=[]
# Data Ckeaning
f= open("Drake.txt","r")
list_toptext=[]
list_bottomtext=[]
while True:
line1 = f.readline().rstrip('\n').lower()
line2 = f.readline().rstrip('\n').lower()
list_toptext.append(line1)
list_bottomtext.append(line2)
if not line1: break
print(list_toptext)
print(len(list_toptext))
for i in range(len(list_toptext)):
string1=list_toptext[i]
string1+=" "
string1+=list_bottomtext[i]
list_prompts.append(string1)
list =[]
print(len(list_prompts))
#print(list_prompts)
prompt=string1
for i in range(0,len(list_toptext)):
prompt+=str(i+1) + "."
prompt+=list_toptext[i] +" "
prompt+=list_bottomtext[i]
print(prompt)
#Text Generation
for i in range(100):
completion = openai.Completion.create(engine="curie", prompt=prompt,max_tokens=20,temperature=0.85) #curie worked pretty well for our cause
list.append(completion.choices[0].text)
with open("drake_generation_100.txt", "w",encoding="utf-8") as textfile:
for element in list:
textfile.write(element + "\n")
textfile.close()