Vipul Swarup commited on
Commit
f69ed2e
·
1 Parent(s): e0e56e1

scaffolding for student input

Browse files
Files changed (1) hide show
  1. app.py +30 -12
app.py CHANGED
@@ -17,6 +17,7 @@ from langchain.schema import (
17
  #App UI starts here
18
  st.set_page_config(page_title="FRQ Generator", page_icon=":robot:")
19
  st.header("FRQs using GPT-4")
 
20
  header_text=str('''
21
  Paste a JSON file here, with the following information:
22
  1. The name of the common core standard,
@@ -42,7 +43,7 @@ if "sessionMessages" not in st.session_state:
42
 
43
 
44
  #Function to return the response
45
- def load_answer(question):
46
  ccStandard = question['cc-standard']
47
  #st.session_state.sessionMessages.append(HumanMessage(content="Common Core standard is: {question[0]}, and the area of interest is: {question[1]}"))
48
 
@@ -77,9 +78,7 @@ def load_answer(question):
77
  passage_and_research = chat(st.session_state.sessionMessages)
78
  st.session_state.sessionMessages.append(AIMessage(content=passage_and_research.content))
79
 
80
- # Print passage
81
- st.write(passage_and_research.content)
82
-
83
  # Based on the above generated passage and research topic, we will now generate 3 FRQs and their grading rubrics
84
  frqPrompt='Generate 3 questions based on the previously discussed common core standard, and the above generated passage. The answers should be available either in the above passage, or the student should be able to find them with easy web research. Good questions have: introduction, context, and open-ended question. Remember, the student is in grade: '+chatResponseDict['grade-level']
85
  frqPrompt+='Generate a rubric for evaluating the student responses for the above questions. Return the result in JSON format. E.g. { "rubric":[{"question":"..text of the question", "rubric":".. text of the rubric"}] etc.'
@@ -89,8 +88,9 @@ def load_answer(question):
89
  question_and_rubric = chat(st.session_state.sessionMessages)
90
  st.session_state.sessionMessages.append(AIMessage(content=question_and_rubric.content))
91
 
92
- # Print rubric & questions
93
- st.write(question_and_rubric.content)
 
94
 
95
  ## Do the QC Step
96
  qcPrompt='For the JSON generated in the previous step, please evaluate for each question and rubric:\
@@ -130,13 +130,12 @@ def load_answer(question):
130
 
131
 
132
 
133
- return ""
134
- # json.loads(assistant_answer.content)
135
 
136
 
137
  #Gets the user input
138
  def get_text():
139
- input_text = st.text_area(label="Paste here")
140
  return input_text
141
 
142
  ## Temperature kept at 0.9, so that generated passages and questions are not too similar to each other.
@@ -157,9 +156,28 @@ if submit:
157
  responseDict=[]
158
  for row in questionArray:
159
  st.write(row)
160
- response = load_answer(row)
161
- st.subheader("Answer:")
162
- st.write(response)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
 
164
 
165
 
 
17
  #App UI starts here
18
  st.set_page_config(page_title="FRQ Generator", page_icon=":robot:")
19
  st.header("FRQs using GPT-4")
20
+ st.subheader("IMPORTANT: Please wait 60-70 seconds between responses. Chat GPT takes time to think.")
21
  header_text=str('''
22
  Paste a JSON file here, with the following information:
23
  1. The name of the common core standard,
 
43
 
44
 
45
  #Function to return the response
46
+ def generateQuestion(question):
47
  ccStandard = question['cc-standard']
48
  #st.session_state.sessionMessages.append(HumanMessage(content="Common Core standard is: {question[0]}, and the area of interest is: {question[1]}"))
49
 
 
78
  passage_and_research = chat(st.session_state.sessionMessages)
79
  st.session_state.sessionMessages.append(AIMessage(content=passage_and_research.content))
80
 
81
+
 
 
82
  # Based on the above generated passage and research topic, we will now generate 3 FRQs and their grading rubrics
83
  frqPrompt='Generate 3 questions based on the previously discussed common core standard, and the above generated passage. The answers should be available either in the above passage, or the student should be able to find them with easy web research. Good questions have: introduction, context, and open-ended question. Remember, the student is in grade: '+chatResponseDict['grade-level']
84
  frqPrompt+='Generate a rubric for evaluating the student responses for the above questions. Return the result in JSON format. E.g. { "rubric":[{"question":"..text of the question", "rubric":".. text of the rubric"}] etc.'
 
88
  question_and_rubric = chat(st.session_state.sessionMessages)
89
  st.session_state.sessionMessages.append(AIMessage(content=question_and_rubric.content))
90
 
91
+
92
+ questionPassageJSON=json.loads(question_and_rubric.content)
93
+
94
 
95
  ## Do the QC Step
96
  qcPrompt='For the JSON generated in the previous step, please evaluate for each question and rubric:\
 
130
 
131
 
132
 
133
+ return questionPassageJSON
 
134
 
135
 
136
  #Gets the user input
137
  def get_text():
138
+ input_text = st.text_area(label="Paste/Write here")
139
  return input_text
140
 
141
  ## Temperature kept at 0.9, so that generated passages and questions are not too similar to each other.
 
156
  responseDict=[]
157
  for row in questionArray:
158
  st.write(row)
159
+ st.subheader("AI Generated Question & Rubric (Note - in a real world scenario, the rubric won't be shown to the student):")
160
+ #response = generateQuestion(row)
161
+ #st.write(response)
162
+ st.subheader("Enter Student's Answer:")
163
+ st.write("Please use question number headers to enter answers:")
164
+ eg_text=str('''
165
+
166
+ Question 1:
167
+ The name of the boy was David, and his main interest was in the game of Cricket.
168
+
169
+ Question 2
170
+ A successful game of cricket involves a strong bowler and batsman.
171
+
172
+ The answers can span multiple lines. Leave empty lines between answers.
173
+
174
+ ''')
175
+ st.markdown(eg_text)
176
+ studentInput = get_text()
177
+ answerButton = st.button('Submit Answer')
178
+ if answerButton:
179
+ st.write (studentInput)
180
+
181
 
182
 
183