Spaces:
Sleeping
Sleeping
exam_history_prompt = f"""
Browse files
app.py
CHANGED
@@ -94,16 +94,105 @@ def generate_points(model, max_tokens, sys_content, scenario, eng_level, topic,
|
|
94 |
def update_points_input(points):
|
95 |
return points
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
def generate_topic_sentences(model, max_tokens, sys_content, scenario, eng_level, topic, points, user_generate_topic_sentences_prompt):
|
98 |
"""
|
99 |
根据系统提示和用户输入的情境及要点,调用OpenAI API生成相关的主题句及其合理性解释。
|
100 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
user_content = f"""
|
102 |
scenario is: {scenario}
|
103 |
english level is: {eng_level}
|
104 |
topic is: {topic}
|
105 |
points is: {points}
|
106 |
---
|
|
|
|
|
107 |
{user_generate_topic_sentences_prompt}
|
108 |
"""
|
109 |
messages = [
|
@@ -504,7 +593,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
504 |
max_tokens = gr.Slider(minimum=50, maximum=4000, value=4000, label="Max Tokens")
|
505 |
sys_content_input = gr.Textbox(label="System Prompt", value="You are an English teacher who is practicing with me to improve my English writing skill.")
|
506 |
with gr.Row():
|
507 |
-
eng_level_input = gr.Radio([("初學", "beginner"), ("中級","intermediate"), ("進階", "advanced"), ("學測指考","
|
508 |
|
509 |
# basic inputs 主題與情境
|
510 |
with gr.Group():
|
|
|
94 |
def update_points_input(points):
|
95 |
return points
|
96 |
|
97 |
+
def get_exam_history():
|
98 |
+
exam_history = """
|
99 |
+
92
|
100 |
+
Topic: Various Exams in High School Life
|
101 |
+
Theme Sentence (First Paragraph): Exams of all kinds have become a necessary part of my high school life.
|
102 |
+
Theme Sentence (Second Paragraph): The most unforgettable exam I have ever taken is…
|
103 |
+
Keywords:
|
104 |
+
giving reasons
|
105 |
+
experience
|
106 |
+
|
107 |
+
93
|
108 |
+
Topic: Travel Is The Best Teacher
|
109 |
+
Theme Sentence (First Paragraph): Explain the advantages of travel.
|
110 |
+
Theme Sentence (Second Paragraph): Share personal travel experiences, either domestic or international, to support the first paragraph.
|
111 |
+
Keywords:
|
112 |
+
enumeration
|
113 |
+
experience
|
114 |
+
|
115 |
+
94
|
116 |
+
Topic: Organizing the First Reunion After Graduation
|
117 |
+
Theme Sentence (First Paragraph): Details of the reunion, including time, location, and activities.
|
118 |
+
Theme Sentence (Second Paragraph): Reasons for choosing this type of activity.
|
119 |
+
Keywords:
|
120 |
+
description
|
121 |
+
giving reasons
|
122 |
+
|
123 |
+
95
|
124 |
+
Topic: Experiences of Being Misunderstood
|
125 |
+
Theme Sentence (First Paragraph): Describe a personal experience of being misunderstood.
|
126 |
+
Theme Sentence (Second Paragraph): Discuss the impact and insights gained from this experience.
|
127 |
+
Keywords:
|
128 |
+
experience
|
129 |
+
effect
|
130 |
+
|
131 |
+
96
|
132 |
+
Topic: Imagining a World Without Electricity
|
133 |
+
Theme Sentence (First Paragraph): Describe what the world would be like without electricity.
|
134 |
+
Theme Sentence (Second Paragraph): Explain whether such a world would be good or bad, with examples.
|
135 |
+
Keywords:
|
136 |
+
description
|
137 |
+
giving reasons
|
138 |
+
|
139 |
+
97
|
140 |
+
Topic: A Memorable Advertisement
|
141 |
+
Theme Sentence (First Paragraph): Describe the content of a memorable TV or print advertisement (e.g., theme, storyline, music, visuals).
|
142 |
+
Theme Sentence (Second Paragraph): Explain why the advertisement is memorable.
|
143 |
+
Keywords:
|
144 |
+
description
|
145 |
+
giving reasons
|
146 |
+
|
147 |
+
98
|
148 |
+
Topic: A Day Without Budget Concerns
|
149 |
+
Theme Sentence (First Paragraph): Who would you invite to spend the day with and why?
|
150 |
+
Theme Sentence (Second Paragraph): Describe where you would go, what you would do, and why.
|
151 |
+
Keywords:
|
152 |
+
description
|
153 |
+
|
154 |
+
99
|
155 |
+
Topic: An Unforgettable Smell
|
156 |
+
Theme Sentence (First Paragraph): Describe the situation in which you encountered the smell and your initial feelings.
|
157 |
+
Theme Sentence (Second Paragraph): Explain why the smell remains unforgettable.
|
158 |
+
Keywords:
|
159 |
+
description
|
160 |
+
giving reasons
|
161 |
+
|
162 |
+
100
|
163 |
+
Topic: Your Ideal Graduation Ceremony
|
164 |
+
Theme Sentence (First Paragraph): Explain the significance of the graduation ceremony to you.
|
165 |
+
Theme Sentence (Second Paragraph): Describe how to arrange or conduct the ceremony to reflect this significance.
|
166 |
+
Keywords:
|
167 |
+
definition
|
168 |
+
enumeration
|
169 |
+
"""
|
170 |
+
|
171 |
+
return exam_history
|
172 |
+
|
173 |
def generate_topic_sentences(model, max_tokens, sys_content, scenario, eng_level, topic, points, user_generate_topic_sentences_prompt):
|
174 |
"""
|
175 |
根据系统提示和用户输入的情境及要点,调用OpenAI API生成相关的主题句及其合理性解释。
|
176 |
"""
|
177 |
+
|
178 |
+
if eng_level == "台灣學科能力測驗等級":
|
179 |
+
exam_history = get_exam_history()
|
180 |
+
exam_history_prompt = f"""
|
181 |
+
Please refer a topic scenario from the following exam history:
|
182 |
+
{exam_history}
|
183 |
+
give similar topic scenario and level of English. But don't use the same topic scenario.
|
184 |
+
"""
|
185 |
+
else:
|
186 |
+
exam_history_prompt = ""
|
187 |
+
|
188 |
user_content = f"""
|
189 |
scenario is: {scenario}
|
190 |
english level is: {eng_level}
|
191 |
topic is: {topic}
|
192 |
points is: {points}
|
193 |
---
|
194 |
+
exam_history_prompt: {exam_history_prompt}
|
195 |
+
---
|
196 |
{user_generate_topic_sentences_prompt}
|
197 |
"""
|
198 |
messages = [
|
|
|
593 |
max_tokens = gr.Slider(minimum=50, maximum=4000, value=4000, label="Max Tokens")
|
594 |
sys_content_input = gr.Textbox(label="System Prompt", value="You are an English teacher who is practicing with me to improve my English writing skill.")
|
595 |
with gr.Row():
|
596 |
+
eng_level_input = gr.Radio([("初學", "beginner"), ("中級","intermediate"), ("進階", "advanced"), ("學測指考","台灣學科能力測驗等級")], label="English Level", value="beginner")
|
597 |
|
598 |
# basic inputs 主題與情境
|
599 |
with gr.Group():
|