Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ls1intum/Artemis into feature/ir…
Browse files Browse the repository at this point in the history
…is/event-service
  • Loading branch information
kaancayli committed Dec 10, 2024
2 parents cc59856 + bb05226 commit 6a36edb
Show file tree
Hide file tree
Showing 31 changed files with 371 additions and 104 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ spotless {
}
}
importOrderFile "artemis-spotless.importorder"
eclipse("4.28").configFile "artemis-spotless-style.xml"
eclipse("4.33").configFile "artemis-spotless-style.xml"

removeUnusedImports()
trimTrailingWhitespace()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package de.tum.cit.aet.artemis.iris.domain.settings;

import jakarta.annotation.Nullable;
import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
* An {@link IrisSubSettings} implementation for course chat settings.
* Chat settings notably provide settings for the rate limit.
*/
@Entity
@DiscriminatorValue("COURSE_CHAT")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class IrisCourseChatSubSettings extends IrisSubSettings {

@Nullable
@Column(name = "rate_limit")
private Integer rateLimit;

@Nullable
@Column(name = "rate_limit_timeframe_hours")
private Integer rateLimitTimeframeHours;

@Nullable
public Integer getRateLimit() {
return rateLimit;
}

public void setRateLimit(@Nullable Integer rateLimit) {
this.rateLimit = rateLimit;
}

@Nullable
public Integer getRateLimitTimeframeHours() {
return rateLimitTimeframeHours;
}

public void setRateLimitTimeframeHours(@Nullable Integer rateLimitTimeframeHours) {
this.rateLimitTimeframeHours = rateLimitTimeframeHours;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class IrisCourseSettings extends IrisSettings {
@JoinColumn(name = "iris_text_exercise_chat_settings_id")
private IrisTextExerciseChatSubSettings irisTextExerciseChatSettings;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "iris_course_chat_settings_id")
private IrisCourseChatSubSettings irisCourseChatSettings;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
@JoinColumn(name = "iris_lecture_ingestion_settings_id")
private IrisLectureIngestionSubSettings irisLectureIngestionSettings;
Expand Down Expand Up @@ -78,6 +82,16 @@ public void setIrisTextExerciseChatSettings(IrisTextExerciseChatSubSettings iris
this.irisTextExerciseChatSettings = irisTextExerciseChatSettings;
}

@Override
public IrisCourseChatSubSettings getIrisCourseChatSettings() {
return irisCourseChatSettings;
}

@Override
public void setIrisCourseChatSettings(IrisCourseChatSubSettings irisCourseChatSettings) {
this.irisCourseChatSettings = irisCourseChatSettings;
}

@Override
public IrisCompetencyGenerationSubSettings getIrisCompetencyGenerationSettings() {
return irisCompetencyGenerationSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ public void setIrisTextExerciseChatSettings(IrisTextExerciseChatSubSettings iris
this.irisTextExerciseChatSettings = irisTextExerciseChatSettings;
}

@Override
public IrisCourseChatSubSettings getIrisCourseChatSettings() {
// Empty because exercises don't have course chat settings
return null;
}

@Override
public void setIrisCourseChatSettings(IrisCourseChatSubSettings irisCourseChatSettings) {
// Empty because exercises don't have course chat settings
}

@Override
public IrisCompetencyGenerationSubSettings getIrisCompetencyGenerationSettings() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public class IrisGlobalSettings extends IrisSettings {
@JoinColumn(name = "iris_text_exercise_chat_settings_id")
private IrisTextExerciseChatSubSettings irisTextExerciseChatSettings;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "iris_course_chat_settings_id")
private IrisCourseChatSubSettings irisCourseChatSettings;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "iris_lecture_ingestion_settings_id")
private IrisLectureIngestionSubSettings irisLectureIngestionSettings;
Expand Down Expand Up @@ -65,6 +69,16 @@ public void setIrisTextExerciseChatSettings(IrisTextExerciseChatSubSettings iris
this.irisTextExerciseChatSettings = irisTextExerciseChatSettings;
}

@Override
public IrisCourseChatSubSettings getIrisCourseChatSettings() {
return irisCourseChatSettings;
}

@Override
public void setIrisCourseChatSettings(IrisCourseChatSubSettings irisCourseChatSettings) {
this.irisCourseChatSettings = irisCourseChatSettings;
}

@Override
public IrisCompetencyGenerationSubSettings getIrisCompetencyGenerationSettings() {
return irisCompetencyGenerationSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public abstract class IrisSettings extends DomainObject {

public abstract void setIrisTextExerciseChatSettings(IrisTextExerciseChatSubSettings irisTextExerciseChatSettings);

public abstract IrisCourseChatSubSettings getIrisCourseChatSettings();

public abstract void setIrisCourseChatSettings(IrisCourseChatSubSettings irisCourseChatSettings);

public abstract IrisLectureIngestionSubSettings getIrisLectureIngestionSettings();

public abstract void setIrisLectureIngestionSettings(IrisLectureIngestionSubSettings irisLectureIngestionSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
@JsonSubTypes({
@JsonSubTypes.Type(value = IrisChatSubSettings.class, name = "chat"),
@JsonSubTypes.Type(value = IrisTextExerciseChatSubSettings.class, name = "text-exercise-chat"),
@JsonSubTypes.Type(value = IrisCourseChatSubSettings.class, name = "course-chat"),
@JsonSubTypes.Type(value = IrisLectureIngestionSubSettings.class, name = "lecture-ingestion"),
@JsonSubTypes.Type(value = IrisCompetencyGenerationSubSettings.class, name = "competency-generation")
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.tum.cit.aet.artemis.iris.domain.settings;

public enum IrisSubSettingsType {
CHAT, // TODO: Split into PROGRAMMING_EXERCISE_CHAT and COURSE_CHAT
TEXT_EXERCISE_CHAT, COMPETENCY_GENERATION, LECTURE_INGESTION
CHAT, // TODO: Rename to PROGRAMMING_EXERCISE_CHAT
TEXT_EXERCISE_CHAT, COURSE_CHAT, COMPETENCY_GENERATION, LECTURE_INGESTION
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.tum.cit.aet.artemis.iris.dto;

import java.util.SortedSet;

import jakarta.annotation.Nullable;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record IrisCombinedCourseChatSubSettingsDTO(boolean enabled, Integer rateLimit, Integer rateLimitTimeframeHours, @Nullable SortedSet<String> allowedVariants,
@Nullable String selectedVariant) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public record IrisCombinedSettingsDTO(
IrisCombinedChatSubSettingsDTO irisChatSettings,
IrisCombinedTextExerciseChatSubSettingsDTO irisTextExerciseChatSettings,
IrisCombinedCourseChatSubSettingsDTO irisCourseChatSettings,
IrisCombinedLectureIngestionSubSettingsDTO irisLectureIngestionSettings,
IrisCombinedCompetencyGenerationSubSettingsDTO irisCompetencyGenerationSettings
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void checkHasAccessTo(User user, IrisCourseChatSession session) {
*/
@Override
public void checkIsFeatureActivatedFor(IrisCourseChatSession session) {
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.CHAT, session.getCourse());
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.COURSE_CHAT, session.getCourse());
}

@Override
Expand Down Expand Up @@ -133,9 +133,9 @@ protected void setLLMTokenUsageParameters(LLMTokenUsageService.LLMTokenUsageBuil
*/
public void onJudgementOfLearningSet(CompetencyJol competencyJol) {
var course = competencyJol.getCompetency().getCourse();

// TODO: Add setting to activate/deactivate course chat for JOLs

if (!irisSettingsService.isEnabledFor(IrisSubSettingsType.COURSE_CHAT, course)) {
return;
}
var user = competencyJol.getUser();
user.hasAcceptedIrisElseThrow();
var session = getCurrentSessionOrCreateIfNotExistsInternal(course, user, false);
Expand All @@ -153,7 +153,7 @@ public void onJudgementOfLearningSet(CompetencyJol competencyJol) {
*/
public IrisCourseChatSession getCurrentSessionOrCreateIfNotExists(Course course, User user, boolean sendInitialMessageIfCreated) {
user.hasAcceptedIrisElseThrow();
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.CHAT, course);
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.COURSE_CHAT, course);
return getCurrentSessionOrCreateIfNotExistsInternal(course, user, sendInitialMessageIfCreated);
}

Expand Down Expand Up @@ -183,7 +183,7 @@ private IrisCourseChatSession getCurrentSessionOrCreateIfNotExistsInternal(Cours
*/
public IrisCourseChatSession createSession(Course course, User user, boolean sendInitialMessage) {
user.hasAcceptedIrisElseThrow();
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.CHAT, course);
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.COURSE_CHAT, course);
return createSessionInternal(course, user, sendInitialMessage);
}

Expand Down
Loading

0 comments on commit 6a36edb

Please sign in to comment.