Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iris: Add course chat settings #9866

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
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;
Hialus marked this conversation as resolved.
Show resolved Hide resolved

@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,16 @@ public void setIrisTextExerciseChatSettings(IrisTextExerciseChatSubSettings iris
this.irisTextExerciseChatSettings = irisTextExerciseChatSettings;
}

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

@Override
public void setIrisCourseChatSettings(IrisCourseChatSubSettings irisCourseChatSettings) {

}
Comment on lines +78 to +80
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a short comment in the boy of this method to justify that it's empty.

Suggested change
public void setIrisCourseChatSettings(IrisCourseChatSubSettings irisCourseChatSettings) {
}
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);
Hialus marked this conversation as resolved.
Show resolved Hide resolved

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 @@ -134,7 +134,7 @@ protected void setLLMTokenUsageParameters(LLMTokenUsageService.LLMTokenUsageBuil
*/
public void onJudgementOfLearningSet(CompetencyJol competencyJol) {
var course = competencyJol.getCompetency().getCourse();
if (!irisSettingsService.isEnabledFor(IrisSubSettingsType.CHAT, course)) {
if (!irisSettingsService.isEnabledFor(IrisSubSettingsType.COURSE_CHAT, course)) {
return;
}
var user = competencyJol.getUser();
Expand All @@ -154,7 +154,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 @@ -184,7 +184,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
Loading