Vipul Swarup commited on
Commit
2b46c32
·
1 Parent(s): 9ae4837

refinement

Browse files
Files changed (1) hide show
  1. app.py +23 -8
app.py CHANGED
@@ -48,18 +48,33 @@ def load_answer(question):
48
  #st.session_state.sessionMessages.append(HumanMessage(content="Common Core standard is: {question[0]}, and the area of interest is: {question[1]}"))
49
 
50
  ## Ask the model to understand the common core standard specified
51
- st.session_state.sessionMessages.append(HumanMessage(content="Read the common core standard :"+ccStandard+" and summarize its key requirements for a student in 3 bullet points. what year grade is the above standard applicable to? Answer in simple one word. E.g. '4th grade',' or 'Kindergarten', or 'Nursery'. Also tell if the student needs to read a passage to complete an assessment related to this standard. \
52
- Return the result in JSON format, with keys including 'grade-level', 'standard-requirement', 'is-passage-required'."))
 
 
 
53
  assistant_answer = chat(st.session_state.sessionMessages)
54
  st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))
55
 
56
- # # Identify which grade the standard applies to, and return the grade in one phrase. E.g. '4th grade' or 'kindergarten'
57
- # st.session_state.sessionMessages.append(HumanMessage(content="what year grade is the above standard applicable to? Answer in simple one word. E.g. '4th grade',' or 'Kindergarten', or 'Nursery'"))
58
- # identifiedGrade = chat(st.session_state.sessionMessages)
59
- # st.session_state.sessionMessages.append(AIMessage(content=identifiedGrade.content))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
- # output=assistant_answer.content+ " and Identified Grade:"+identifiedGrade.content
62
- # print (output)
63
  return json.loads(assistant_answer.content)
64
 
65
 
 
48
  #st.session_state.sessionMessages.append(HumanMessage(content="Common Core standard is: {question[0]}, and the area of interest is: {question[1]}"))
49
 
50
  ## Ask the model to understand the common core standard specified
51
+ st.session_state.sessionMessages.append(HumanMessage(content="Read the common core standard :"+ccStandard+" and summarize its key requirements for a student in 3 bullet points. what year grade is the above standard applicable to? Answer in simple one word. E.g. '4th grade',' or 'Kindergarten', or 'Nursery'.\
52
+ Also tell if the student needs to read a passage to complete an assessment related to this standard. \
53
+ Also tell if the student needs to independently research a topic to complete an assessment related to this standard. \
54
+ Also tell if the standard requires testing on a math problem. \
55
+ Return the result in JSON format, with keys including 'grade-level', 'standard-requirement', 'is-passage-required', 'is-research-required', 'is-math-problem'."))
56
  assistant_answer = chat(st.session_state.sessionMessages)
57
  st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))
58
 
59
+ passagePrompt="The area of interest to consider for the exercise is "+question['area-of-interest']+". "
60
+ # Create a JSON Object out of the Chat response
61
+ chatResponseDict = json.loads(assistant_answer.content)
62
+
63
+ if (not chatResponseDict['is-math-problem']):
64
+ #If a passage is required, generate a 300 word passage, for the appropriate grade level.
65
+ if (chatResponseDict['is-passage-required']):
66
+ passagePrompt+="Generate a 300 word passage on the given area of interest. It should cover the key points being tested in the common core standard specified. It should draw on real life incidents. Make it about one particular incident that highlights various things about "+question['area-of-interest']+"."
67
+ #If external research is required, inform the student what to do research on.
68
+ if (chatResponseDict['is-research-required']):
69
+ passagePrompt+="Also suggest what specific topic or idea the student can do external research on, to be able to answer questions related to the common core standard specified. Use language as if you are speaking to the student directly."
70
+
71
+ passagePrompt+="Make sure any passage or topics generated are appropriate in terms of vocabulary and comprehensibility for grade "+chatResponseDict['grade-level']
72
+ passagePrompt+="Return the response in JSON format."
73
+ # Ask the model
74
+ st.session_state.sessionMessages.append(HumanMessage(content=passagePrompt))
75
+ assistant_answer = chat(st.session_state.sessionMessages)
76
+ st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))
77
 
 
 
78
  return json.loads(assistant_answer.content)
79
 
80