-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompts_v2.py
50 lines (44 loc) · 1.42 KB
/
prompts_v2.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
48
49
50
import openai
import os
openai.api_key = os.environ.get("OPENAI_API_KEY")
def prompt_maker(genre, topic, words):
# if len(words)>0:
prompt = f"""write a very long and easy {genre} about {topic} using these words: {words}"""
# else:
# prompt = f"""write a very long and easy {genre} about {topic}"""
return prompt
# add "simple" to the prompt get that Taiwan style writing
# adding easy makes it easy, but always short
# def picture_maker(prompt):
def question_writer(genre,text):
questions_prompt = f"""{text}
Write 8 multiple choice TOEIC-type questions with 4 answer choices about the {genre}:
Questions:"""
print("questions_prompt", questions_prompt)
return questions_prompt
def model_builder(genre, prompt):
if genre=="Article":
temperature = 0.95
frequency_penalty = 0.25
elif genre=="Dialog":
temperature = 0.95
frequency_penalty = 0.25
elif genre == "write_questions":
temperature = 0.70
frequency_penalty = 0
else:
temperature = 0.8
frequency_penalty = 0.25
response = openai.Completion.create(
model="text-davinci-003",
# model = "text-curie-001",
prompt = prompt,
temperature=temperature,
max_tokens=1000,
top_p=1.0,
frequency_penalty=frequency_penalty,
presence_penalty=0.0
)
print (response)
text = response.choices[0].text
return text