Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public LectureQuestionResponse handleUserQuestion(String userQuestion, UUID cour
if ("proactivefeedback".equalsIgnoreCase(userQuestion.trim())) {
Optional<String> feedback = proactiveFeedbackService.getAndDeleteLatestFeedback(currentUser.getId());
if (feedback.isPresent()) {
log.info("Retrieved proactive feedback for user {}", currentUser.getId());
return new LectureQuestionResponse(feedback.get(), List.of());
} else {
log.info("No proactive feedback available for user {}", currentUser.getId());
return new LectureQuestionResponse("No proactive feedback available at the moment.", List.of());
}
}

log.info("[TUTOR] User {} asked question: {}", currentUser.getId(), userQuestion);

CategorizedQuestion categorizedQuestion = preprocessQuestion(userQuestion);

TutorCategory category = categorizedQuestion.getCategory();
Expand Down Expand Up @@ -361,6 +361,7 @@ private LectureQuestionResponse answerCodeFeedbackQuestion(String question, UUID
studentCodeSubmissionService.getCodeSubmissionsForStudent(currentUser.getId());

if (submissions.isEmpty()) {
log.info("[TUTOR-CODE-FEEDBACK] No code submissions found for user {}", currentUser.getId());
return new LectureQuestionResponse(
CODE_FEEDBACK_NO_SUBMISSION_MESSAGE,
List.of());
Expand All @@ -372,6 +373,7 @@ private LectureQuestionResponse answerCodeFeedbackQuestion(String question, UUID
.orElse(null);

if (mostRecentSubmission == null) {
log.info("[TUTOR-CODE-FEEDBACK] Most recent submission is null for user {}", currentUser.getId());
return new LectureQuestionResponse(
CODE_FEEDBACK_NO_SUBMISSION_MESSAGE,
List.of());
Expand All @@ -382,6 +384,8 @@ private LectureQuestionResponse answerCodeFeedbackQuestion(String question, UUID
mostRecentSubmission.getPrimaryKey().getAssignmentId());

if (codeContext.isEmpty()) {
log.info("[TUTOR-CODE-FEEDBACK] Code context is empty for user {} and assignment {}",
currentUser.getId(), mostRecentSubmission.getPrimaryKey().getAssignmentId());
return new LectureQuestionResponse(
CODE_FEEDBACK_NO_SUBMISSION_MESSAGE,
List.of());
Expand All @@ -390,6 +394,9 @@ private LectureQuestionResponse answerCodeFeedbackQuestion(String question, UUID
String conversationHistory = conversationHistoryService.formatHistoryForPrompt(
currentUser.getId(), courseId);

log.info("[TUTOR-CODE-FEEDBACK] Preparing to query LLM for code feedback - user: {}, assignment: {}, code context length: {}",
currentUser.getId(), mostRecentSubmission.getPrimaryKey().getAssignmentId(), codeContext.get().length());

String prompt = ollamaService.getTemplate(PROMPT_TEMPLATES.get(2));
List<TemplateArgs> promptArgs = List.of(
TemplateArgs.builder().argumentName("question").argumentValue(question).build(),
Expand All @@ -404,6 +411,7 @@ private LectureQuestionResponse answerCodeFeedbackQuestion(String question, UUID
conversationHistoryService.addConversationExchange(
currentUser.getId(), courseId, question, response.getAnswer());

log.info("[TUTOR-CODE-FEEDBACK] Code feedback response generated for user {}", currentUser.getId());
return new LectureQuestionResponse(response.getAnswer(), List.of());
}

Expand Down
Loading