Vipul Swarup commited on
Commit
9ae4837
·
1 Parent(s): dd2524f
Files changed (2) hide show
  1. app.py +34 -6
  2. requirements.txt +1 -0
app.py CHANGED
@@ -4,6 +4,7 @@
4
 
5
  import streamlit as st
6
  import json
 
7
 
8
  from langchain.chat_models import ChatOpenAI
9
  from langchain.schema import (
@@ -17,27 +18,54 @@ 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
 
21
  if "sessionMessages" not in st.session_state:
22
  st.session_state.sessionMessages = [
23
- SystemMessage(content = "You are a bot that generates 'free response questions' for assesing school students based on the input of a Common Core Standard, and area of interest.\
24
- If the common core standard involves reading a passage, then also generate a passage of exactly 300 words, and use real world examples. Provide an introduction and clear context for the questions.\
25
- To answer the questions, the student should only need to read the presented text and should not need to refer to external sources.")
26
  ]
27
 
28
 
29
  #Function to return the response
30
  def load_answer(question):
 
31
  #st.session_state.sessionMessages.append(HumanMessage(content="Common Core standard is: {question[0]}, and the area of interest is: {question[1]}"))
32
- st.session_state.sessionMessages.append(HumanMessage(content=str(question)))
 
 
 
33
  assistant_answer = chat(st.session_state.sessionMessages)
34
  st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))
35
- return assistant_answer.content
 
 
 
 
 
 
 
 
36
 
37
 
38
  #Gets the user input
39
  def get_text():
40
- input_text = st.text_area("Paste a JSON file here, with the following keys:(1) The name of the common core standard, (2) The student's area of interest. E.g. {\"cc-standard\": \"CCSS.ELA-LITERACY.W.4.9\", \"area-of-interest\": \"Baseball\" } ", key="input")
41
  return input_text
42
 
43
  chat = ChatOpenAI(temperature=0, model_name="gpt-4")
 
4
 
5
  import streamlit as st
6
  import json
7
+ import markdown
8
 
9
  from langchain.chat_models import ChatOpenAI
10
  from langchain.schema import (
 
18
  #App UI starts here
19
  st.set_page_config(page_title="FRQ Generator", page_icon=":robot:")
20
  st.header("FRQs using GPT-4")
21
+ header_text=str('''
22
+ Paste a JSON file here, with the following information:
23
+ 1. The name of the common core standard,
24
+ 2. The student's area of interest.
25
+
26
+ E.g.
27
+ ```
28
+ {
29
+ 'input':'frq-generator',
30
+ 'entries':[
31
+ {'cc-standard': 'CCSS.ELA-LITERACY.W.4.9', 'area-of-interest': 'Baseball' },
32
+ {'cc-standard': 'CCSS.ELA-LITERACY.W.5.8', 'area-of-interest': 'Hiking' }
33
+ ]
34
+ }
35
+ ```
36
+ ''')
37
+ st.markdown(header_text)
38
 
39
  if "sessionMessages" not in st.session_state:
40
  st.session_state.sessionMessages = [
41
+ SystemMessage(content = "You are a bot that generates 'free response questions' for assesing school students based on the input of a Common Core Standard, and area of interest.")
 
 
42
  ]
43
 
44
 
45
  #Function to return the response
46
  def load_answer(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
+
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
 
66
  #Gets the user input
67
  def get_text():
68
+ input_text = st.text_area(label="Paste here")
69
  return input_text
70
 
71
  chat = ChatOpenAI(temperature=0, model_name="gpt-4")
requirements.txt CHANGED
@@ -3,3 +3,4 @@ Openai
3
  Streamlit
4
  streamlit-chat
5
  python-dotenv
 
 
3
  Streamlit
4
  streamlit-chat
5
  python-dotenv
6
+ markdown