Spaces:
Runtime error
Runtime error
Vipul Swarup commited on
Commit ·
9ae4837
1
Parent(s): dd2524f
Updates
Browse filesFiles changed (2)
- app.py+34-6
- requirements.txt+1
3 unmodified lines4567897 unmodified lines1718192021222324252627282930313233343536373839404142433 unmodified linesimport streamlit as stimport jsonfrom langchain.chat_models import ChatOpenAIfrom langchain.schema import (7 unmodified lines#App UI starts herest.set_page_config(page_title="FRQ Generator", page_icon=":robot:")st.header("FRQs using GPT-4")if "sessionMessages" not in st.session_state:st.session_state.sessionMessages = [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.\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.\To answer the questions, the student should only need to read the presented text and should not need to refer to external sources.")]#Function to return the responsedef load_answer(question):#st.session_state.sessionMessages.append(HumanMessage(content="Common Core standard is: {question[0]}, and the area of interest is: {question[1]}"))st.session_state.sessionMessages.append(HumanMessage(content=str(question)))assistant_answer = chat(st.session_state.sessionMessages)st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))return assistant_answer.content#Gets the user inputdef get_text():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")return input_textchat = ChatOpenAI(temperature=0, model_name="gpt-4")3 unmodified lines456789107 unmodified lines1819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970713 unmodified linesimport streamlit as stimport jsonimport markdownfrom langchain.chat_models import ChatOpenAIfrom langchain.schema import (7 unmodified lines#App UI starts herest.set_page_config(page_title="FRQ Generator", page_icon=":robot:")st.header("FRQs using GPT-4")header_text=str('''Paste a JSON file here, with the following information:1. The name of the common core standard,2. The student's area of interest.E.g.```{'input':'frq-generator','entries':[{'cc-standard': 'CCSS.ELA-LITERACY.W.4.9', 'area-of-interest': 'Baseball' },{'cc-standard': 'CCSS.ELA-LITERACY.W.5.8', 'area-of-interest': 'Hiking' }]}```''')st.markdown(header_text)if "sessionMessages" not in st.session_state:st.session_state.sessionMessages = [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.")]#Function to return the responsedef load_answer(question):ccStandard = question['cc-standard']#st.session_state.sessionMessages.append(HumanMessage(content="Common Core standard is: {question[0]}, and the area of interest is: {question[1]}"))## Ask the model to understand the common core standard specifiedst.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. \Return the result in JSON format, with keys including 'grade-level', 'standard-requirement', 'is-passage-required'."))assistant_answer = chat(st.session_state.sessionMessages)st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))# # Identify which grade the standard applies to, and return the grade in one phrase. E.g. '4th grade' or 'kindergarten'# 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'"))# identifiedGrade = chat(st.session_state.sessionMessages)# st.session_state.sessionMessages.append(AIMessage(content=identifiedGrade.content))# output=assistant_answer.content+ " and Identified Grade:"+identifiedGrade.content# print (output)return json.loads(assistant_answer.content)#Gets the user inputdef get_text():input_text = st.text_area(label="Paste here")return input_textchat = ChatOpenAI(temperature=0, model_name="gpt-4")
2 unmodified lines3452 unmodified linesStreamlitstreamlit-chatpython-dotenv2 unmodified lines34562 unmodified linesStreamlitstreamlit-chatpython-dotenvmarkdown
app.py+34-6
requirements.txt+1