Spaces:
Sleeping
Sleeping
jeremierostan
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -20,10 +20,10 @@ def extract_text_from_pdf(pdf_file_path):
|
|
20 |
# Function to generate different types of questions using Groq
|
21 |
def generate_questions(paper_text):
|
22 |
prompts = [
|
23 |
-
f"
|
24 |
-
f"
|
25 |
-
f"
|
26 |
-
f"Read the student's paper
|
27 |
]
|
28 |
|
29 |
questions = []
|
@@ -39,9 +39,8 @@ def generate_questions(paper_text):
|
|
39 |
# Validate each student's answer with the corresponding question and context
|
40 |
def validate_answer(paper_text, question, student_answer):
|
41 |
prompt = (
|
42 |
-
f"
|
43 |
-
f"
|
44 |
-
f"Determine if the answer is aligned with the ideas or terminology used in the paper. "
|
45 |
f"Paper text: '{paper_text}'\n\nQuestion: '{question}'\n\nStudent's answer: '{student_answer}'"
|
46 |
)
|
47 |
|
@@ -94,7 +93,6 @@ def handle_pdf_upload(pdf_file):
|
|
94 |
# Return the generated questions for display to the user
|
95 |
return questions
|
96 |
|
97 |
-
# Update the handle_answer_submission to accept each answer separately
|
98 |
def handle_answer_submission(pdf_file, student_code, answer1, answer2, answer3, answer4):
|
99 |
# Extract the paper text for validation
|
100 |
pdf_file_path = pdf_file.name
|
@@ -152,13 +150,23 @@ with gr.Blocks() as app:
|
|
152 |
submit_btn = gr.Button("Submit Answers")
|
153 |
# Now passing answers individually
|
154 |
submit_btn.click(fn=handle_answer_submission, inputs=[pdf_file, student_code, answer1, answer2, answer3, answer4], outputs=output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
# Launch the app
|
157 |
app.launch()
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
src="https://groq.com/wp-content/uploads/2024/03/PBG-mark1-color.svg"
|
162 |
-
alt="Powered by Groq for fast inference."
|
163 |
-
/>
|
164 |
-
</a>
|
|
|
20 |
# Function to generate different types of questions using Groq
|
21 |
def generate_questions(paper_text):
|
22 |
prompts = [
|
23 |
+
f"You are Seshat, an app designed to check student understanding and authorship of their written submissions. The student just submitted a paper. Read the student's paper, then ask the following: Based on the paper, ask the student to briefly summarize the outline of the paper. Please address the student directly. Paper text: '{paper_text}'",
|
24 |
+
f"You are Seshat, an app designed to check student understanding and authorship of their written submissions. The student just submitted a paper. Read the student's paper, then ask the following:Based on the paper, identify a key term that is central to the discussion. Ask the student to explain this term in context (provide an excerpt from the paper). Please address the student directly. Paper text: '{paper_text}'",
|
25 |
+
f"You are Seshat, an app designed to check student understanding and authorship of their written submissions. The student just submitted a paper. Read the student's paper, then ask the following:Based on the student's paper, find a key concept or idea. Ask the student how this concept can be applied to a different real-world scenario. Please address the student directly. Paper text: '{paper_text}'",
|
26 |
+
f"You are Seshat, an app designed to check student understanding and authorship of their written submissions. The student just submitted a paper. Read the student's paper, then ask the following:Based on the student's paper, create a either a true or a false (but plausible) statement related to the content. Ask the student to determine if the statement is true or false. Please address the student directly. Paper text: '{paper_text}'"
|
27 |
]
|
28 |
|
29 |
questions = []
|
|
|
39 |
# Validate each student's answer with the corresponding question and context
|
40 |
def validate_answer(paper_text, question, student_answer):
|
41 |
prompt = (
|
42 |
+
f"You are Seshat, an app designed to check student understanding and authorship of their written submissions."
|
43 |
+
f"You asked the student questions based on the paper they submitted. Compare the student's answer to the content of the paper to determine whether they understand its content, and are therefore its likely author; or if this might require further investigation."
|
|
|
44 |
f"Paper text: '{paper_text}'\n\nQuestion: '{question}'\n\nStudent's answer: '{student_answer}'"
|
45 |
)
|
46 |
|
|
|
93 |
# Return the generated questions for display to the user
|
94 |
return questions
|
95 |
|
|
|
96 |
def handle_answer_submission(pdf_file, student_code, answer1, answer2, answer3, answer4):
|
97 |
# Extract the paper text for validation
|
98 |
pdf_file_path = pdf_file.name
|
|
|
150 |
submit_btn = gr.Button("Submit Answers")
|
151 |
# Now passing answers individually
|
152 |
submit_btn.click(fn=handle_answer_submission, inputs=[pdf_file, student_code, answer1, answer2, answer3, answer4], outputs=output)
|
153 |
+
|
154 |
+
# Add the "Powered by Groq" logo and link at the bottom
|
155 |
+
with gr.Row():
|
156 |
+
gr.Markdown(
|
157 |
+
"""
|
158 |
+
<a href="https://groq.com" target="_blank" rel="noopener noreferrer">
|
159 |
+
<img
|
160 |
+
src="https://groq.com/wp-content/uploads/2024/03/PBG-mark1-color.svg"
|
161 |
+
alt="Powered by Groq for fast inference."
|
162 |
+
style="width: 200px;"
|
163 |
+
/>
|
164 |
+
</a>
|
165 |
+
"""
|
166 |
+
)
|
167 |
|
168 |
# Launch the app
|
169 |
app.launch()
|
170 |
|
171 |
+
|
172 |
+
|
|
|
|
|
|
|
|