-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/communication/send-faq-to-iris
- Loading branch information
Showing
139 changed files
with
2,777 additions
and
852 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/de/tum/cit/aet/artemis/core/config/LicenseConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package de.tum.cit.aet.artemis.core.config; | ||
|
||
import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; | ||
|
||
import jakarta.annotation.Nullable; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Profile; | ||
|
||
@Profile(PROFILE_CORE) | ||
@ConfigurationProperties(prefix = "artemis.licenses") | ||
public class LicenseConfiguration { | ||
|
||
private final MatLabLicense matlab; | ||
|
||
public record MatLabLicense(String licenseServer) { | ||
} | ||
|
||
public LicenseConfiguration(MatLabLicense matlab) { | ||
this.matlab = matlab; | ||
} | ||
|
||
@Nullable | ||
public String getMatlabLicenseServer() { | ||
if (matlab == null) { | ||
return null; | ||
} | ||
return matlab.licenseServer(); | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
src/main/java/de/tum/cit/aet/artemis/iris/service/IrisConsistencyCheckService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package de.tum.cit.aet.artemis.iris.service; | ||
|
||
import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_IRIS; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Service; | ||
|
||
import de.tum.cit.aet.artemis.core.domain.Course; | ||
import de.tum.cit.aet.artemis.core.domain.LLMServiceType; | ||
import de.tum.cit.aet.artemis.core.domain.User; | ||
import de.tum.cit.aet.artemis.core.repository.UserRepository; | ||
import de.tum.cit.aet.artemis.core.service.LLMTokenUsageService; | ||
import de.tum.cit.aet.artemis.exercise.domain.Exercise; | ||
import de.tum.cit.aet.artemis.exercise.repository.ExerciseRepository; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.PyrisDTOService; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.PyrisJobService; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.PyrisPipelineService; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.dto.consistencyCheck.PyrisConsistencyCheckPipelineExecutionDTO; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.dto.consistencyCheck.PyrisConsistencyCheckStatusUpdateDTO; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.job.ConsistencyCheckJob; | ||
import de.tum.cit.aet.artemis.iris.service.websocket.IrisWebsocketService; | ||
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise; | ||
|
||
/** | ||
* Service to handle the rewriting subsystem of Iris. | ||
*/ | ||
@Service | ||
@Profile(PROFILE_IRIS) | ||
public class IrisConsistencyCheckService { | ||
|
||
private final PyrisPipelineService pyrisPipelineService; | ||
|
||
private final LLMTokenUsageService llmTokenUsageService; | ||
|
||
private final ExerciseRepository exerciseRepository; | ||
|
||
private final IrisWebsocketService websocketService; | ||
|
||
private final PyrisJobService pyrisJobService; | ||
|
||
private final UserRepository userRepository; | ||
|
||
private final PyrisDTOService pyrisDTOService; | ||
|
||
public IrisConsistencyCheckService(PyrisPipelineService pyrisPipelineService, LLMTokenUsageService llmTokenUsageService, ExerciseRepository exerciseRepository, | ||
IrisWebsocketService websocketService, PyrisJobService pyrisJobService, UserRepository userRepository, PyrisDTOService pyrisDTOService) { | ||
this.pyrisPipelineService = pyrisPipelineService; | ||
this.llmTokenUsageService = llmTokenUsageService; | ||
this.exerciseRepository = exerciseRepository; | ||
this.websocketService = websocketService; | ||
this.pyrisJobService = pyrisJobService; | ||
this.userRepository = userRepository; | ||
this.pyrisDTOService = pyrisDTOService; | ||
} | ||
|
||
/** | ||
* Executes the consistency check pipeline on Pyris | ||
* | ||
* @param user the user for which the pipeline should be executed | ||
* @param exercise the exercise for which the pipeline should be executed | ||
*/ | ||
public void executeConsistencyCheckPipeline(User user, ProgrammingExercise exercise) { | ||
Course course = exercise.getCourseViaExerciseGroupOrCourseMember(); | ||
// @formatter:off | ||
pyrisPipelineService.executePipeline( | ||
"inconsistency-check", | ||
"default", | ||
Optional.empty(), | ||
pyrisJobService.createTokenForJob(token -> new ConsistencyCheckJob(token, course.getId(), exercise.getId(), user.getId())), | ||
executionDto -> new PyrisConsistencyCheckPipelineExecutionDTO(executionDto, pyrisDTOService.toPyrisProgrammingExerciseDTO(exercise)), | ||
stages -> websocketService.send(user.getLogin(), websocketTopic(exercise.getId()), new PyrisConsistencyCheckStatusUpdateDTO(stages, null, null)) | ||
); | ||
// @formatter:on | ||
} | ||
|
||
/** | ||
* Takes a status update from Pyris containing a new consistency check result and sends it to the client via websocket | ||
* | ||
* @param job Job related to the status update | ||
* @param statusUpdate the status update containing the consistency check result | ||
* @return the same job that was passed in | ||
*/ | ||
public ConsistencyCheckJob handleStatusUpdate(ConsistencyCheckJob job, PyrisConsistencyCheckStatusUpdateDTO statusUpdate) { | ||
Exercise exercise = exerciseRepository.findByIdElseThrow(job.exerciseId()); | ||
if (statusUpdate.tokens() != null && !statusUpdate.tokens().isEmpty()) { | ||
llmTokenUsageService.saveLLMTokenUsage(statusUpdate.tokens(), LLMServiceType.IRIS, builder -> builder.withExercise(exercise.getId()).withUser(job.userId())); | ||
} | ||
|
||
var user = userRepository.findById(job.userId()).orElseThrow(); | ||
websocketService.send(user.getLogin(), websocketTopic(job.exerciseId()), statusUpdate); | ||
|
||
return job; | ||
} | ||
|
||
private static String websocketTopic(long exerciseId) { | ||
return "consistency-check/exercises/" + exerciseId; | ||
} | ||
|
||
} |
97 changes: 97 additions & 0 deletions
97
src/main/java/de/tum/cit/aet/artemis/iris/service/IrisRewritingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package de.tum.cit.aet.artemis.iris.service; | ||
|
||
import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_IRIS; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Service; | ||
|
||
import de.tum.cit.aet.artemis.core.domain.Course; | ||
import de.tum.cit.aet.artemis.core.domain.LLMServiceType; | ||
import de.tum.cit.aet.artemis.core.domain.User; | ||
import de.tum.cit.aet.artemis.core.repository.CourseRepository; | ||
import de.tum.cit.aet.artemis.core.repository.UserRepository; | ||
import de.tum.cit.aet.artemis.core.service.LLMTokenUsageService; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.PyrisJobService; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.PyrisPipelineService; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.dto.rewriting.PyrisRewritingPipelineExecutionDTO; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.dto.rewriting.PyrisRewritingStatusUpdateDTO; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.dto.rewriting.RewritingVariant; | ||
import de.tum.cit.aet.artemis.iris.service.pyris.job.RewritingJob; | ||
import de.tum.cit.aet.artemis.iris.service.websocket.IrisWebsocketService; | ||
|
||
/** | ||
* Service to handle the rewriting subsystem of Iris. | ||
*/ | ||
@Service | ||
@Profile(PROFILE_IRIS) | ||
public class IrisRewritingService { | ||
|
||
private final PyrisPipelineService pyrisPipelineService; | ||
|
||
private final LLMTokenUsageService llmTokenUsageService; | ||
|
||
private final CourseRepository courseRepository; | ||
|
||
private final IrisWebsocketService websocketService; | ||
|
||
private final PyrisJobService pyrisJobService; | ||
|
||
private final UserRepository userRepository; | ||
|
||
public IrisRewritingService(PyrisPipelineService pyrisPipelineService, LLMTokenUsageService llmTokenUsageService, CourseRepository courseRepository, | ||
IrisWebsocketService websocketService, PyrisJobService pyrisJobService, UserRepository userRepository) { | ||
this.pyrisPipelineService = pyrisPipelineService; | ||
this.llmTokenUsageService = llmTokenUsageService; | ||
this.courseRepository = courseRepository; | ||
this.websocketService = websocketService; | ||
this.pyrisJobService = pyrisJobService; | ||
this.userRepository = userRepository; | ||
} | ||
|
||
/** | ||
* Executes the rewriting pipeline on Pyris | ||
* | ||
* @param user the user for which the pipeline should be executed | ||
* @param course the course for which the pipeline should be executed | ||
* @param variant the rewriting variant to be used | ||
* @param toBeRewritten the text to be rewritten | ||
*/ | ||
public void executeRewritingPipeline(User user, Course course, RewritingVariant variant, String toBeRewritten) { | ||
// @formatter:off | ||
pyrisPipelineService.executePipeline( | ||
"rewriting", | ||
variant.toString(), | ||
Optional.empty(), | ||
pyrisJobService.createTokenForJob(token -> new RewritingJob(token, course.getId(), user.getId())), | ||
executionDto -> new PyrisRewritingPipelineExecutionDTO(executionDto, toBeRewritten), | ||
stages -> websocketService.send(user.getLogin(), websocketTopic(course.getId()), new PyrisRewritingStatusUpdateDTO(stages, null, null)) | ||
); | ||
// @formatter:on | ||
} | ||
|
||
/** | ||
* Takes a status update from Pyris containing a new rewriting result and sends it to the client via websocket | ||
* | ||
* @param job Job related to the status update | ||
* @param statusUpdate the status update containing text recommendations | ||
* @return the same job that was passed in | ||
*/ | ||
public RewritingJob handleStatusUpdate(RewritingJob job, PyrisRewritingStatusUpdateDTO statusUpdate) { | ||
Course course = courseRepository.findByIdForUpdateElseThrow(job.courseId()); | ||
if (statusUpdate.tokens() != null && !statusUpdate.tokens().isEmpty()) { | ||
llmTokenUsageService.saveLLMTokenUsage(statusUpdate.tokens(), LLMServiceType.IRIS, builder -> builder.withCourse(course.getId()).withUser(job.userId())); | ||
} | ||
|
||
var user = userRepository.findById(job.userId()).orElseThrow(); | ||
websocketService.send(user.getLogin(), websocketTopic(job.courseId()), statusUpdate); | ||
|
||
return job; | ||
} | ||
|
||
private static String websocketTopic(long courseId) { | ||
return "rewriting/" + courseId; | ||
} | ||
|
||
} |
Oops, something went wrong.