Spaces:
Runtime error
Runtime error
Vipul Swarup commited on
Commit ·
609654e
1
Parent(s): f69ed2e
scaffolding for student input
Browse files
Pipfile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[[source]]
|
| 2 |
+
url = "https://pypi.org/simple"
|
| 3 |
+
verify_ssl = true
|
| 4 |
+
name = "pypi"
|
| 5 |
+
|
| 6 |
+
[packages]
|
| 7 |
+
langchain = "*"
|
| 8 |
+
openai = "*"
|
| 9 |
+
streamlit = "*"
|
| 10 |
+
streamlit-chat = "*"
|
| 11 |
+
python-dotenv = "*"
|
| 12 |
+
markdown = "*"
|
| 13 |
+
|
| 14 |
+
[dev-packages]
|
| 15 |
+
|
| 16 |
+
[requires]
|
| 17 |
+
python_version = "3.11"
|
app.py
CHANGED
|
@@ -44,6 +44,7 @@ if "sessionMessages" not in st.session_state:
|
|
| 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 |
|
|
@@ -89,7 +90,7 @@ def generateQuestion(question):
|
|
| 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
|
|
@@ -130,18 +131,19 @@ def generateQuestion(question):
|
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
-
return
|
| 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.
|
| 142 |
chat = ChatOpenAI(temperature=0.9, model_name="gpt-4")
|
| 143 |
|
| 144 |
-
user_input = get_text()
|
| 145 |
|
| 146 |
|
| 147 |
|
|
@@ -152,31 +154,18 @@ if submit:
|
|
| 152 |
# Create a dict object from the JSON input
|
| 153 |
inputDict = json.loads(user_input)
|
| 154 |
questionArray=inputDict['entries']
|
|
|
|
| 155 |
# iterate through the dict, and create a new dict with each response from the LLM
|
| 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 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
| 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 |
|
|
|
|
| 44 |
|
| 45 |
#Function to return the response
|
| 46 |
def generateQuestion(question):
|
| 47 |
+
questionPassageJSON=""
|
| 48 |
ccStandard = question['cc-standard']
|
| 49 |
#st.session_state.sessionMessages.append(HumanMessage(content="Common Core standard is: {question[0]}, and the area of interest is: {question[1]}"))
|
| 50 |
|
|
|
|
| 90 |
st.session_state.sessionMessages.append(AIMessage(content=question_and_rubric.content))
|
| 91 |
|
| 92 |
|
| 93 |
+
#questionPassageJSON=json.loads(question_and_rubric.content)
|
| 94 |
|
| 95 |
|
| 96 |
## Do the QC Step
|
|
|
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
+
return question_and_rubric.content
|
| 135 |
|
| 136 |
|
| 137 |
#Gets the user input
|
| 138 |
+
def get_text(textAreaKey):
|
| 139 |
+
input_text = st.text_area(label="Paste/Write here",key=textAreaKey)
|
| 140 |
+
textAreaKey+=1
|
| 141 |
return input_text
|
| 142 |
|
| 143 |
## Temperature kept at 0.9, so that generated passages and questions are not too similar to each other.
|
| 144 |
chat = ChatOpenAI(temperature=0.9, model_name="gpt-4")
|
| 145 |
|
| 146 |
+
user_input = get_text(1)
|
| 147 |
|
| 148 |
|
| 149 |
|
|
|
|
| 154 |
# Create a dict object from the JSON input
|
| 155 |
inputDict = json.loads(user_input)
|
| 156 |
questionArray=inputDict['entries']
|
| 157 |
+
responseArray=[]
|
| 158 |
# iterate through the dict, and create a new dict with each response from the LLM
|
| 159 |
responseDict=[]
|
| 160 |
for row in questionArray:
|
| 161 |
st.write(row)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
+
response = generateQuestion(row)
|
| 164 |
+
responseArray.append(response)
|
| 165 |
+
|
| 166 |
+
st.subheader("AI Generated Question & Rubric (Note - in a real world scenario, the rubric won't be shown to the student):")
|
| 167 |
+
st.write(responseArray)
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
|
| 171 |
|