forked from hollobit/ttmik
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvogen.py
More file actions
37 lines (27 loc) · 911 Bytes
/
Copy pathconvogen.py
File metadata and controls
37 lines (27 loc) · 911 Bytes
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
"""
Use OpenAI API to generate fake conversations using our vocabulary so far.
"""
import openai
# query openai api
openai.api_key = open("oaikey.txt", "r").read().strip()
know = open("convonotes.md", 'r').read()
TEMPLATE = """
Generate a conversation in Korean. Only incorporate the concepts I've learned about so far. I am attaching my study notes below.
MY NOTES:
""".strip()
prompt = TEMPLATE + "\n" + know
for i in range(5):
resp = openai.ChatCompletion.create(
model="gpt-3.5-turbo-16k",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt},
]
)
# we want to extract the content from the response
result = resp["choices"][0]["message"]["content"]
print(result)
# write result to file
print(i+1)
with open(f"convos/convo{i+1}.txt", 'w') as f:
f.write(result)