|
1 | 1 | package de.unistuttgart.iste.meitrex.assignment_service.service.uml_assignment; |
2 | 2 |
|
3 | | -import de.unistuttgart.iste.meitrex.assignment_service.controller.UmlTestController; |
4 | 3 | import de.unistuttgart.iste.meitrex.assignment_service.exception.AiEvaluationException; |
5 | 4 | import de.unistuttgart.iste.meitrex.assignment_service.persistence.entity.umlExercise.UmlEvaluationJobEntity; |
6 | 5 | import de.unistuttgart.iste.meitrex.assignment_service.persistence.entity.umlExercise.UmlFeedbackEntity; |
@@ -161,94 +160,6 @@ private UmlFeedbackResponse performGrading( |
161 | 160 | return response; |
162 | 161 | } |
163 | 162 |
|
164 | | - /** |
165 | | - * Executes the evaluation pipeline without saving to the database. |
166 | | - * Returns granular timings for benchmarking LLM configurations. |
167 | | - */ |
168 | | - public UmlTestController.TestEvalResponse dryRunEvaluation( |
169 | | - final String studentModel, |
170 | | - final String tutorModel, |
171 | | - final String gradingRules, |
172 | | - final int maxPoints, |
173 | | - final double requiredPercentage, |
174 | | - final String analysisModelOverride, |
175 | | - final String gradingModelOverride, |
176 | | - final String promptMode, |
177 | | - final String taskDescription |
178 | | - ) { |
179 | | - long startTotal = System.currentTimeMillis(); |
180 | | - |
181 | | - // 1. Run Analysis with Timer |
182 | | - long startAnalysis = System.currentTimeMillis(); |
183 | | - Map<String, String> analysisArgs = new HashMap<>(); |
184 | | - analysisArgs.put("studentModel", studentModel); |
185 | | - |
186 | | - UmlAnalysisResponse fallbackAnalysis = new UmlAnalysisResponse( |
187 | | - Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), false, "Analysis failed." |
188 | | - ); |
189 | | - |
190 | | - String prompt; |
191 | | - if ("TASK_BASED".equals(promptMode)) { |
192 | | - prompt = "analysis_task.md"; |
193 | | - analysisArgs.put("taskDescription", taskDescription); |
194 | | - analysisArgs.put("tutorModel", tutorModel); |
195 | | - } else if ("PURE_TASK".equals(promptMode)) { |
196 | | - prompt = "uml_analysis_pure_task.md"; |
197 | | - analysisArgs.put("taskDescription", taskDescription); |
198 | | - } else { |
199 | | - prompt = TEMPLATE_ANALYSIS; |
200 | | - analysisArgs.put("tutorModel", tutorModel); |
201 | | - } |
202 | | - |
203 | | - UmlAnalysisResponse analysis = ollamaClient.startQuery( |
204 | | - UmlAnalysisResponse.class, prompt, analysisArgs, fallbackAnalysis, analysisModelOverride); |
205 | | - |
206 | | - long endAnalysis = System.currentTimeMillis(); |
207 | | - double analysisDuration = (endAnalysis - startAnalysis) / 1000.0; |
208 | | - |
209 | | - if ("Analysis failed.".equals(analysis.analysisSummary())) { |
210 | | - throw new RuntimeException("Analysis LLM failed during dry run."); |
211 | | - } |
212 | | - |
213 | | - // 2. Run Grading with Timer |
214 | | - long startGrading = System.currentTimeMillis(); |
215 | | - String effectiveRules = (gradingRules != null && !gradingRules.isBlank()) ? gradingRules : "Standard UML grading."; |
216 | | - Map<String, String> gradingArgs = Map.of( |
217 | | - "maxPoints", String.valueOf(maxPoints), |
218 | | - "passingThreshold", String.valueOf(requiredPercentage * maxPoints), |
219 | | - "showSolution", "true", |
220 | | - "gradingRules", effectiveRules, |
221 | | - "isValid", String.valueOf(analysis.isSemanticallyValid()), |
222 | | - "correctElements", formatListForPrompt(analysis.correctElements()), |
223 | | - "semanticErrors", formatListForPrompt(analysis.semanticErrors()), |
224 | | - "missingElements", formatListForPrompt(analysis.missingElements()) |
225 | | - ); |
226 | | - |
227 | | - UmlFeedbackResponse fallbackGrading = new UmlFeedbackResponse("Grading unavailable.", 0); |
228 | | - |
229 | | - UmlFeedbackResponse grading = ollamaClient.startQuery( |
230 | | - UmlFeedbackResponse.class, TEMPLATE_GRADING, gradingArgs, fallbackGrading, gradingModelOverride); |
231 | | - |
232 | | - long endGrading = System.currentTimeMillis(); |
233 | | - double gradingDuration = (endGrading - startGrading) / 1000.0; |
234 | | - |
235 | | - if ("Grading unavailable.".equals(grading.feedbackText())) { |
236 | | - throw new RuntimeException("Grading LLM failed during dry run."); |
237 | | - } |
238 | | - |
239 | | - long endTotal = System.currentTimeMillis(); |
240 | | - double totalDuration = (endTotal - startTotal) / 1000.0; |
241 | | - |
242 | | - // Return the combined payload |
243 | | - return new UmlTestController.TestEvalResponse( |
244 | | - grading.points(), |
245 | | - grading.feedbackText(), |
246 | | - analysisDuration, |
247 | | - gradingDuration, |
248 | | - totalDuration |
249 | | - ); |
250 | | - } |
251 | | - |
252 | 163 | /** |
253 | 164 | * Safely formats a list of strings into a single semicolon-separated string. |
254 | 165 | * <p> |
|
0 commit comments