Skip to content

Commit

Permalink
Updating feedback code
Browse files Browse the repository at this point in the history
  • Loading branch information
gitchrisqueen committed Apr 20, 2024
1 parent 52fc732 commit 7051d9a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
22 changes: 12 additions & 10 deletions src/cqc_cpcc/project_feedback.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime as DT
from pprint import pprint
from typing import Optional, Annotated, List

from docx import Document
Expand Down Expand Up @@ -296,22 +295,25 @@ def process_submission_from_link(driver: WebDriver, wait: WebDriverWait, url: st


async def get_feedback_guide(assignment: str,
solution: str, student_submission: str, course_name: str, wrap_code_in_markdown=True,
custom_llm: BaseChatModel = None, callback: BaseCallbackHandler = None) -> FeedbackGuide:
solution: str, student_submission: str, course_name: str,
feedback_type_list: list,
wrap_code_in_markdown=True,
custom_llm: BaseChatModel = None, callback: BaseCallbackHandler = None) -> FeedbackGuide:
if custom_llm is None:
custom_llm = get_default_llm()

feedback_from_llm = await generate_feedback(custom_llm, FeedbackGuide, DefaultFeedbackType.list(), assignment, solution,
student_submission, course_name, wrap_code_in_markdown, callback)
feedback_from_llm = await generate_feedback(custom_llm, FeedbackGuide, feedback_type_list, assignment,
solution,
student_submission, course_name, wrap_code_in_markdown, callback)

#print("\n\nFinal Output From LLM:")
#pprint(feedback_from_llm)
# print("\n\nFinal Output From LLM:")
# pprint(feedback_from_llm)

feedback_guide = FeedbackGuide.parse_obj(feedback_from_llm)

if COMMENTS_MISSING_STRING in DefaultFeedbackType.list():

#print("\n\nFinding Correct Error Line Numbers")
# print("\n\nFinding Correct Error Line Numbers")
jc = JavaCode(entire_raw_code=student_submission)

if feedback_guide.all_feedback is not None:
Expand All @@ -333,13 +335,13 @@ async def get_feedback_guide(assignment: str,
error_details="There is not enough comments to help others understand the purpose, functionality, and structure of the code.")

if jc.sufficient_amount_of_comments:
#print("Found Insufficient comments error by LLM but not true so removing")
# print("Found Insufficient comments error by LLM but not true so removing")
# Sufficient comments so remove this error type
unique_feedback = [x for x in unique_feedback if
x.error_type != DefaultFeedbackType.CSC_151_PROJECT_ALL_COMMENTS_MISSING]
elif DefaultFeedbackType.CSC_151_PROJECT_ALL_COMMENTS_MISSING not in [x.error_type for x in
unique_feedback]:
#print("Did not find Insufficient comments error by LLM but true so adding it")
# print("Did not find Insufficient comments error by LLM but true so adding it")
# Insufficient comments but error type doesnt exist
unique_feedback.insert(0, insufficient_comment_error)

Expand Down
36 changes: 22 additions & 14 deletions src/cqc_streamlit_app/pages/2_Give_Feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,13 @@ async def get_feedback_content():
total_student_submissions = len(student_submissions_map)
for base_student_filename, student_submission_files_map in student_submissions_map.items():
tasks.append(add_feedback_status_extender(
base_student_filename,
student_submission_files_map,
course_name,
assignment_instructions_content,
str(assignment_solution_contents),
custom_llm,
base_student_filename=base_student_filename,
filename_file_path_map=student_submission_files_map,
course_name=course_name,
feedback_type_list=feedback_types_list,
assignment_instructions=assignment_instructions_content,
assignment_solution=str(assignment_solution_contents),
custom_llm=custom_llm
))

else:
Expand All @@ -260,12 +261,14 @@ async def get_feedback_content():
# Add a new expander element with grade and feedback from the grader class

tasks.append(add_feedback_status_extender(
base_student_filename,
{base_student_filename: student_submission_temp_file_path},
course_name,
assignment_instructions_content,
str(assignment_solution_contents),
custom_llm))
base_student_filename=base_student_filename,
filename_file_path_map={base_student_filename: student_submission_temp_file_path},
course_name=course_name,
feedback_type_list=feedback_types_list,
assignment_instructions=assignment_instructions_content,
assignment_solution=str(assignment_solution_contents),
custom_llm=custom_llm
))

results = await asyncio.gather(*tasks)

Expand Down Expand Up @@ -314,8 +317,12 @@ async def get_feedback_content():
"""


async def add_feedback_status_extender(base_student_filename: str, filename_file_path_map: dict,
course_name: str, assignment_instructions: str, assignment_solution: str,
async def add_feedback_status_extender(base_student_filename: str,
filename_file_path_map: dict,
course_name: str,
feedback_type_list: list,
assignment_instructions: str,
assignment_solution: str,
custom_llm: BaseChatModel):
base_student_filename = base_student_filename.replace(" ", "_")

Expand Down Expand Up @@ -373,6 +380,7 @@ async def add_feedback_status_extender(base_student_filename: str, filename_file
solution=assignment_solution,
student_submission=student_submission_file_path_contents,
course_name=course_name,
feedback_type_list=feedback_type_list,
custom_llm=custom_llm,
wrap_code_in_markdown=wrap_code_in_markdown,
callback=ChatGPTStatusCallbackHandler(status, status_prefix_label)
Expand Down

0 comments on commit 7051d9a

Please sign in to comment.