Update pdf_processor.py
Browse files- pdf_processor.py +0 -7
pdf_processor.py
CHANGED
|
@@ -6,14 +6,10 @@ from llm import get_llm
|
|
| 6 |
llm = get_llm()
|
| 7 |
|
| 8 |
def extract_answers_from_pdf(pdf_path: str) -> ExtractionResult:
|
| 9 |
-
"""
|
| 10 |
-
Loads a PDF, extracts its content, and uses the LLM to output a JSON of the answers.
|
| 11 |
-
"""
|
| 12 |
loader = PyPDFLoader(pdf_path)
|
| 13 |
pages = loader.load_and_split()
|
| 14 |
all_page_content = "\n".join(page.page_content for page in pages)
|
| 15 |
|
| 16 |
-
# Build the system message with JSON schema instructions.
|
| 17 |
extraction_schema = ExtractionResult.model_json_schema()
|
| 18 |
system_message = (
|
| 19 |
"You are a document analysis tool that extracts the options and correct answers from the provided document content. "
|
|
@@ -30,9 +26,6 @@ def extract_answers_from_pdf(pdf_path: str) -> ExtractionResult:
|
|
| 30 |
return result
|
| 31 |
|
| 32 |
def evaluate_student(answer_key: ExtractionResult, student: ExtractionResult) -> EvaluationResult:
|
| 33 |
-
"""
|
| 34 |
-
Compares the answer key with a student's answers and returns the evaluation result.
|
| 35 |
-
"""
|
| 36 |
evaluation_schema = EvaluationResult.model_json_schema()
|
| 37 |
system_message = (
|
| 38 |
"You are an academic evaluation tool that compares the answer key with a student's answers. "
|
|
|
|
| 6 |
llm = get_llm()
|
| 7 |
|
| 8 |
def extract_answers_from_pdf(pdf_path: str) -> ExtractionResult:
|
|
|
|
|
|
|
|
|
|
| 9 |
loader = PyPDFLoader(pdf_path)
|
| 10 |
pages = loader.load_and_split()
|
| 11 |
all_page_content = "\n".join(page.page_content for page in pages)
|
| 12 |
|
|
|
|
| 13 |
extraction_schema = ExtractionResult.model_json_schema()
|
| 14 |
system_message = (
|
| 15 |
"You are a document analysis tool that extracts the options and correct answers from the provided document content. "
|
|
|
|
| 26 |
return result
|
| 27 |
|
| 28 |
def evaluate_student(answer_key: ExtractionResult, student: ExtractionResult) -> EvaluationResult:
|
|
|
|
|
|
|
|
|
|
| 29 |
evaluation_schema = EvaluationResult.model_json_schema()
|
| 30 |
system_message = (
|
| 31 |
"You are an academic evaluation tool that compares the answer key with a student's answers. "
|