Spaces:
Sleeping
Sleeping
Commit
·
92b013c
1
Parent(s):
66c56a3
Update app.py
Browse files
app.py
CHANGED
@@ -40,17 +40,12 @@ with gr.Blocks() as app:
|
|
40 |
dialog_state.append("Student: "+input)
|
41 |
dialog = "\n\n".join(dialog_state)
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
prompt_summary = prompt_summary.format(dialog=last_4)
|
47 |
-
response_summary = api_call(prompt_summary, model)
|
48 |
-
if not "[NO_INFORMATION]" in response_summary:
|
49 |
-
memory+="\n"+response_summary
|
50 |
-
counter += 1
|
51 |
|
|
|
52 |
prompt = base_prompt.format(tutor=tutor, dialog=dialog, response_student=input, memory=memory)
|
53 |
-
|
54 |
response_full = api_call(prompt, model)
|
55 |
response_tutor = parse(response_full)
|
56 |
|
@@ -78,147 +73,99 @@ and use simple language in order to be on the same level as the student."""
|
|
78 |
Take on the role of the AI tutor described and formulate the tutor's next answer.
|
79 |
Try to use short, concise sentences and only give one piece of information at a time or ask one question at a time.
|
80 |
Proceed step by step:
|
81 |
-
|
82 |
-
|
83 |
-
what situation you are currently in in the dialog. Summarize all relevant information for your next answer and the current situation.
|
84 |
-
situation. This includes the current task being worked on, any supporting materials such as texts, diagrams or additional information
|
85 |
-
and all information about the student's level of knowledge that you have collected so far.
|
86 |
STUDENT: Analyze the student's last answer in detail. This is: "{response_student}". Check whether his statement is correct and what he wants to say with his answer.
|
87 |
-
|
88 |
-
|
89 |
-
response. Do not lose sight of the main goal of the dialog
|
90 |
-
MESSAGE_STUDENT: Repeat the student's last message again here
|
91 |
TUTOR: Formulate your answer sentence
|
92 |
|
93 |
Here are some examples:
|
94 |
Example 1:
|
95 |
-
|
96 |
-
- The topic of the homework is the fall of the Berlin Wall
|
97 |
-
MESSAGE_STUDENT: "I'm working on my history homework and can't get any further. It's about the fall of the Berlin Wall. I don't understand it anyway."
|
98 |
-
ANALYSIS: The student needs help with his history homework. I know that it's about the fall of the Berlin Wall,
|
99 |
but I don't know the exact task yet. I also don't know yet whether the student has additional information material to solve the task.
|
100 |
-
The main task of the dialog is to solve the homework about the fall of the Berlin Wall. At the moment, however, we haven't started working on it yet.
|
101 |
-
I am still collecting further information about the task and possible materials that could help us.
|
102 |
STUDENT: The student has described his problem in more detail. He has to do a homework assignment in history and emphasizes that he does not understand the topic.
|
103 |
understood the topic. He seems unmotivated and frustrated.
|
104 |
-
STRATEGY:
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
|
|
110 |
|
111 |
Example 2:
|
112 |
-
|
113 |
-
|
114 |
-
- The student knows the form ax^2 + bx +c = 0
|
115 |
-
- The student should read from the equation 5x^2+2x+4 = 0 what the letters stand for
|
116 |
-
- The student names the answer a=5, b=2 and c=4
|
117 |
-
- The student knows the midnight formula
|
118 |
-
- The student inserts the parameters a=5, b=2 and c=4 into the midnight formula and calculates the correct result
|
119 |
-
- The student should solve an exercise independently, the task is: Solve the equation 2x^2+4x+8=4
|
120 |
-
- The student has read the parameters a,b and c from the equation, his answer is a=2 b=4 and c=8.
|
121 |
-
MESSAGE_STUDENT: "So now I have to find the values for a, b and c for the midnight formula. That should be a=2 b=4 and c=8."
|
122 |
-
ANALYSIS: The student needs help because they haven't understood a topic in math class. I already know that it is about solving quadratic equations.
|
123 |
-
quadratic equations. The student does not have a specific homework assignment that he wants to solve, but wants to better understand and practice the topic. I have already
|
124 |
already found out that the teacher demonstrated the midnight formula in class and not the PQ formula. In the course of the lesson so far, the
|
125 |
student has already learned to first put the equation into normal form and then insert the parameters a,b and c into the midnight formula.
|
126 |
Now the student has tried to apply what he has learned in a problem. The problem is 2x^2+4x+8=4. He has started to insert numbers into the midnight formula
|
127 |
but forgot to convert the equation to normal form first.
|
128 |
STUDENT: In his last answer, the student has started to solve the problem. He read the parameters of the midnight formula from the equation
|
129 |
-
and inserted them into the formula.
|
130 |
The student must first transform the equation so that there is 0 on one side. Only then can the midnight formula be applied.
|
131 |
-
STRATEGY: I have to tell the student that the answer is not correct.
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
TUTOR: "Careful, you've forgotten something. What was the first step again before we can use the midnight formula?"
|
137 |
|
138 |
Example 3:
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
ANALYSIS: The student would like help with his geography homework on the topic of polar regions. I already know the exact text of the task: Work out the differences
|
144 |
-
between the Arctic and the Antarctic. However, I don't know what the text says. I don't know whether the student has already read the text.
|
145 |
-
I also don't know what aspects of the Arctic and Antarctic were discussed in class.
|
146 |
-
STUDENT: In his last message, the student read out the exact assignment text. Since it was not an answer to a factual question,
|
147 |
the student's answer is most likely CORRECT. He is cooperative and seems to want to complete the task quickly. But he also wants to understand the solution.
|
148 |
STRATEGY: I know the exact task, but I don't know the extent to which the topic was covered in class. I have to
|
149 |
make sure that my explanation does not go beyond the subject matter covered in class so as not to overwhelm the student. I assume that the student
|
150 |
has either covered the necessary knowledge for the task in class or that there is additional information material on the task. It is important
|
151 |
-
that we use this information as a guide so that the student can learn the subject matter effectively. I should
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
155 |
|
156 |
Example 4:
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
- The student has difficulty understanding the diagram
|
163 |
-
- The student does not seem to know what the input and output materials are in photosynthesis
|
164 |
-
- The tutor gives a brief explanation of the input and output substances in photosynthesis
|
165 |
-
- The student should describe again in their own words which substances are converted during photosynthesis
|
166 |
-
- The student answers that photosynthesis converts carbon dioxide and water into oxygen and sugar
|
167 |
-
- The student's answer is correct and they state that they now have a better understanding of the conversion of substances during photosynthesis
|
168 |
-
MESSAGE_STUDENT: "Ah, okay, I think I've got it now."
|
169 |
-
ANALYSIS: The main task is for the student to solve the following task: "Explain the process of photosynthesis using the diagram". It seems to be a
|
170 |
-
flow chart that shows the different steps of photosynthesis. The student initially had difficulty
|
171 |
-
to name the input and output substances of photosynthesis. I was able to close these gaps in his knowledge with an explanation and the student was able to
|
172 |
-
his answer in his own words to prove that he now knows that photosynthesis converts carbon dioxide and water into oxygen and sugar.
|
173 |
STUDENT: In his last message, the student confirms that he now understands which substances are converted during photosynthesis.
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
that have not yet been explained.
|
185 |
-
INFORMATION: {memory}
|
186 |
-
MESSAGE_STUDENT: "{response_student}"
|
187 |
ANALYSIS:
|
188 |
-
STUDENT:
|
189 |
-
STRATEGY:
|
190 |
-
|
|
|
191 |
"""
|
192 |
|
193 |
-
base_prompt_summary = """
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
- The
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
- The student does not have a specific task but wants to understand the topic better
|
210 |
-
|
211 |
-
Example 3:
|
212 |
-
DIALOGUE: Student: "Hey"
|
213 |
-
Tutor: "Hello, how can I help you?"
|
214 |
-
Student: "Who are you?"
|
215 |
-
Tutor: "I'm a digital tutor. I'm here to help you with questions and problems around school. What can I do for you?"
|
216 |
-
Student: "Nothing, just wanted to say hello"
|
217 |
-
A: [NO_INFORMATION]
|
218 |
-
|
219 |
-
Use the examples as a guide and extract the most important information from this dialog excerpt:
|
220 |
-
DIALOG: {dialog}
|
221 |
-
A:"""
|
222 |
|
223 |
|
224 |
|
@@ -230,7 +177,7 @@ A:"""
|
|
230 |
txt_input = gr.Textbox(label="New Message", lines=4)
|
231 |
btn_submit = gr.Button("Submit")
|
232 |
btn_download = gr.DownloadButton(label="Download Dialog", visible=False)
|
233 |
-
txt_memory = gr.Textbox(label="Memory", lines=10, interactive=False, value ="-
|
234 |
txt_response = gr.Textbox(label="Analysis Tutor", lines=10, interactive=False)
|
235 |
|
236 |
|
|
|
40 |
dialog_state.append("Student: "+input)
|
41 |
dialog = "\n\n".join(dialog_state)
|
42 |
|
43 |
+
# MEMORY UPDATE
|
44 |
+
prompt_summary = prompt_summary.format(dialog=dialog, memory = memory)
|
45 |
+
memory = api_call(prompt_summary, model)
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
+
# TUTOR RESPONSE
|
48 |
prompt = base_prompt.format(tutor=tutor, dialog=dialog, response_student=input, memory=memory)
|
|
|
49 |
response_full = api_call(prompt, model)
|
50 |
response_tutor = parse(response_full)
|
51 |
|
|
|
73 |
Take on the role of the AI tutor described and formulate the tutor's next answer.
|
74 |
Try to use short, concise sentences and only give one piece of information at a time or ask one question at a time.
|
75 |
Proceed step by step:
|
76 |
+
ANALYSIS: Analyze the dialogue so far and summarize what you know about the student's situation. Describe what the student's goal is,
|
77 |
+
Do they want to solve a specific task or just understand a topic better? Does he have additional materials from the lesson or in the book that could help?
|
|
|
|
|
|
|
78 |
STUDENT: Analyze the student's last answer in detail. This is: "{response_student}". Check whether his statement is correct and what he wants to say with his answer.
|
79 |
+
STRATEGY: Explain what your strategy and next step as a tutor should be
|
80 |
+
INPUT: Repeat the student's last answer here again
|
|
|
|
|
81 |
TUTOR: Formulate your answer sentence
|
82 |
|
83 |
Here are some examples:
|
84 |
Example 1:
|
85 |
+
ANALYSIS: The student needs help with his history homework. I know that it is about the fall of the Berlin Wall,
|
|
|
|
|
|
|
86 |
but I don't know the exact task yet. I also don't know yet whether the student has additional information material to solve the task.
|
|
|
|
|
87 |
STUDENT: The student has described his problem in more detail. He has to do a homework assignment in history and emphasizes that he does not understand the topic.
|
88 |
understood the topic. He seems unmotivated and frustrated.
|
89 |
+
STRATEGY: In order to be able to support the student effectively, I need more information about the task he has to solve and his previous knowledge.
|
90 |
+
previous knowledge. I should first ask him to read out the task. Since the topic is very large and complex, I assume that only part of it
|
91 |
+
was covered in class. I should therefore find out later whether there are any notes or texts from the lessons that we could use as a guide.
|
92 |
+
we could use for orientation. Then we can work through the task together step by step. I should
|
93 |
+
motivate him additionally, as he seems frustrated and unmotivated.
|
94 |
+
INPUT: "I'm working on my history homework and can't get any further. It's about the fall of the Berlin Wall. I don't understand it anyway."
|
95 |
+
TUTOR: "No problem! Why don't you read me the assignment first? I'm sure we'll get it right!"
|
96 |
|
97 |
Example 2:
|
98 |
+
ANALYSIS: The student needs help because he didn't understand a topic in math class. I already know that it's about solving quadratic equations.
|
99 |
+
quadratic equations. The student doesn't have a specific homework assignment that they want to solve, but wants to understand the topic better and practise. I have already
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
already found out that the teacher demonstrated the midnight formula in class and not the PQ formula. In the course of the lesson so far, the
|
101 |
student has already learned to first put the equation into normal form and then insert the parameters a,b and c into the midnight formula.
|
102 |
Now the student has tried to apply what he has learned in a problem. The problem is 2x^2+4x+8=4. He has started to insert numbers into the midnight formula
|
103 |
but forgot to convert the equation to normal form first.
|
104 |
STUDENT: In his last answer, the student has started to solve the problem. He read the parameters of the midnight formula from the equation
|
105 |
+
and inserted them into the formula. The student's answer is FALSE because the equation is not in normal form. Correction:
|
106 |
The student must first transform the equation so that there is 0 on one side. Only then can the midnight formula be applied.
|
107 |
+
STRATEGY: I have to tell the student that the answer is not correct. The student has the necessary knowledge to solve the problem, so I believe that
|
108 |
+
I believe that he can correct his mistake himself. I should not tell him the correct solution but point out to him
|
109 |
+
that he has made a mistake and give him a little tip. He should think again and correct the mistake himself.
|
110 |
+
INPUT: "So now I have to find the values for a, b and c for the midnight formula. That should be a=2 b=4 and c=8. "
|
111 |
+
TUTOR: "Careful, you've forgotten something. What was the first step again before we can apply the midnight formula?"
|
|
|
112 |
|
113 |
Example 3:
|
114 |
+
ANALYSIS: The student wants help with his geography homework on the topic of polar regions. I already know the exact task text: Work out the differences
|
115 |
+
between the Arctic and the Antarctic. However, I don't yet know whether this was discussed in class and whether the student should solve the task
|
116 |
+
solve the task using information material.
|
117 |
+
STUDENT: In his last message, the student read out the exact text of the task. Since it was not an answer to a factual question,
|
|
|
|
|
|
|
|
|
118 |
the student's answer is most likely CORRECT. He is cooperative and seems to want to complete the task quickly. But he also wants to understand the solution.
|
119 |
STRATEGY: I know the exact task, but I don't know the extent to which the topic was covered in class. I have to
|
120 |
make sure that my explanation does not go beyond the subject matter covered in class so as not to overwhelm the student. I assume that the student
|
121 |
has either covered the necessary knowledge for the task in class or that there is additional information material on the task. It is important
|
122 |
+
that we use this information as a guide so that the student can learn the subject matter effectively. So I should find out
|
123 |
+
what was covered in class on the topic and whether there is any further information.
|
124 |
+
INPUT: "Okay, it says here: Work out the differences between the Arctic and Antarctic from the text."
|
125 |
+
TUTOR: "All right, thanks for reading. It says here that you should work out the differences between the Arctic and Antarctic. Is there any text or pictures on the
|
126 |
+
text or any pictures on the task sheet that could help you? Or did you write something down in class?"
|
127 |
|
128 |
Example 4:
|
129 |
+
ANALYSIS: The student needs help with his biology homework on the subject of photosynthesis. Using a diagram, he should explain the process of photosynthesis
|
130 |
+
explain. I don't know the diagram, but the student has described it to me. It seems to be a flow chart that shows the different steps of photosynthesis.
|
131 |
+
of photosynthesis. The student had problems with some of the terms, but we have now clarified them. It then became clear that
|
132 |
+
the student does not yet know what the input and output products of photosynthesis are. We also discussed this together and he came to the conclusion himself that
|
133 |
+
that photosynthesis converts carbon dioxide and water into oxygen and sugar.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
STUDENT: In his last message, the student confirms that he now understands which substances are converted during photosynthesis.
|
135 |
+
STRATEGY: I must not lose sight of the actual goal. The student wants to solve the task. We have now clarified some comprehension problems
|
136 |
+
and should now return to the task. The student should now have the necessary background knowledge and I should encourage them to
|
137 |
+
to try again himself. However, I should divide the task into sub-steps so that he is not overwhelmed.
|
138 |
+
INPUT: "Ah, okay, I think I've got it now."
|
139 |
+
TUTOR: "Great! Then we can get back to the actual task. You're supposed to describe the process using the diagram.
|
140 |
+
Why don't you start with the first step? Try to formulate a sentence that describes the first step. "
|
141 |
+
|
142 |
+
Use the examples as a guide and proceed step by step. Here is the most important information about the student's situation:
|
143 |
+
{memory}
|
144 |
+
Take this information into account when analyzing and formulating your answer. Formulate the tutor's final answer in simple and
|
145 |
+
language to be on the same level as the student. Avoid technical terms that have not yet been explained.
|
|
|
|
|
146 |
ANALYSIS:
|
147 |
+
STUDENT:
|
148 |
+
STRATEGY:
|
149 |
+
INPUT: "{response_student}"
|
150 |
+
TUTOR:
|
151 |
"""
|
152 |
|
153 |
+
base_prompt_summary = """What follows is a dialog between a student and a tutor and a list of information that is known so far.
|
154 |
+
Analyze the dialogue and then provide an updated list of information. This means: Proceed step by step and evaluate for each piece of
|
155 |
+
information whether it is still valid. If the information is still valid, then copy it word-for-word into the new list without changing it.
|
156 |
+
If the information is no longer valid, do NOT transfer it to the new list but leave it out. If new information emerges from the dialog
|
157 |
+
that is not yet included in the list, add it to the updated list. Only edit the most relevant information
|
158 |
+
from the dialog and ONLY the information that concerns the student and their tasks. If specific tasks are discussed,
|
159 |
+
ALWAYS copy the task word for word and do not summarize it or leave anything out. Start each piece of information with "The student ...". Here are some examples:
|
160 |
+
- The student needs help with his geography homework.
|
161 |
+
- The student does not know the term "mitochondrion"
|
162 |
+
- The student has to solve the following task: "Read the text T1. a) Work out the factors that led to the French Revolution. b) Describe the king's behavior"
|
163 |
+
- The student has tried to put the equation into normal form. His answer is: "x^2+5x+3=0"
|
164 |
+
- The student must solve the following task: "Calculate the first derivative of the following function:f(x)=e^x+2x"
|
165 |
+
The dialog and the previous information follows. ALWAYS give your answer in GERMAN.
|
166 |
+
DIALOGUE: {dialog}
|
167 |
+
INFORMATION: {memory}
|
168 |
+
UPDATED INFORMATION:"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
|
171 |
|
|
|
177 |
txt_input = gr.Textbox(label="New Message", lines=4)
|
178 |
btn_submit = gr.Button("Submit")
|
179 |
btn_download = gr.DownloadButton(label="Download Dialog", visible=False)
|
180 |
+
txt_memory = gr.Textbox(label="Memory", lines=10, interactive=False, value ="-The Student needs assistance by the tutor")
|
181 |
txt_response = gr.Textbox(label="Analysis Tutor", lines=10, interactive=False)
|
182 |
|
183 |
|