diff --git a/src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.java b/src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.java index e0ca91845ea..308b119d3cf 100644 --- a/src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.java +++ b/src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.java @@ -1,8 +1,6 @@ package org.jabref.gui.ai.components.aichat; import javafx.application.Platform; -import javafx.beans.property.IntegerProperty; -import javafx.beans.property.SimpleIntegerProperty; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.ProgressIndicator; @@ -30,7 +28,6 @@ import dev.langchain4j.data.message.UserMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import scala.concurrent.impl.FutureConvertersImpl; public class AiChatComponent extends VBox { private static final Logger LOGGER = LoggerFactory.getLogger(AiChatComponent.class); @@ -73,6 +70,12 @@ public void initialize() { } }); + scrollPane.needsLayoutProperty().addListener((observable, oldValue, newValue) -> { + if (!newValue) { + scrollPane.setVvalue(1.0); + } + }); + chatVBox .getChildren() .addAll(aiChatLogic.getChatHistory() diff --git a/src/main/java/org/jabref/logic/ai/FileEmbeddingsManager.java b/src/main/java/org/jabref/logic/ai/FileEmbeddingsManager.java index 24133bdd1e4..48e07d61a6b 100644 --- a/src/main/java/org/jabref/logic/ai/FileEmbeddingsManager.java +++ b/src/main/java/org/jabref/logic/ai/FileEmbeddingsManager.java @@ -54,10 +54,7 @@ public FileEmbeddingsManager(AiPreferences aiPreferences, ReadOnlyBooleanPropert } private void setupListeningToPreferencesChanges() { - aiPreferences.addListenerToEmbeddingsParametersChange(() -> { - embeddingStore.removeAll(); - fullyIngestedDocumentsTracker.unmarkAll(); - }); + aiPreferences.addListenerToEmbeddingsParametersChange(embeddingStore::removeAll); } public void addDocument(String link, Document document, long modificationTimeInSeconds, IntegerProperty workDone, IntegerProperty workMax) throws InterruptedException { diff --git a/src/main/java/org/jabref/logic/ai/embeddings/FullyIngestedDocumentsTracker.java b/src/main/java/org/jabref/logic/ai/embeddings/FullyIngestedDocumentsTracker.java index dbb2fcdc3dc..90c6e17813c 100644 --- a/src/main/java/org/jabref/logic/ai/embeddings/FullyIngestedDocumentsTracker.java +++ b/src/main/java/org/jabref/logic/ai/embeddings/FullyIngestedDocumentsTracker.java @@ -56,8 +56,4 @@ public void unmarkDocumentAsFullyIngested(String link) { public Set getFullyIngestedDocuments() { return new HashSet<>(ingestedMap.keySet()); } - - public void unmarkAll() { - ingestedMap.clear(); - } } diff --git a/src/main/java/org/jabref/logic/ai/models/JabRefEmbeddingModel.java b/src/main/java/org/jabref/logic/ai/models/JabRefEmbeddingModel.java index 451778bcb4e..7ac288d22a0 100644 --- a/src/main/java/org/jabref/logic/ai/models/JabRefEmbeddingModel.java +++ b/src/main/java/org/jabref/logic/ai/models/JabRefEmbeddingModel.java @@ -104,7 +104,13 @@ private void setupListeningToPreferencesChanges() { } }); - aiPreferences.addListenerToEmbeddingsParametersChange(this::startRebuildingTask); + aiPreferences.customizeExpertSettingsProperty().addListener((obs, oldValue, newValue) -> { + if (newValue && predictorProperty.get().isEmpty()) { + startRebuildingTask(); + } + }); + + aiPreferences.embeddingModelProperty().addListener(obs -> startRebuildingTask()); } @Override diff --git a/src/main/java/org/jabref/preferences/ai/AiPreferences.java b/src/main/java/org/jabref/preferences/ai/AiPreferences.java index 507e9fc8e92..a3ae3b2fefb 100644 --- a/src/main/java/org/jabref/preferences/ai/AiPreferences.java +++ b/src/main/java/org/jabref/preferences/ai/AiPreferences.java @@ -335,12 +335,6 @@ public void setRagMinScore(double ragMinScore) { * @param runnable The runnable that should be executed when the preferences change. */ public void addListenerToEmbeddingsParametersChange(Runnable runnable) { - customizeExpertSettings.addListener((observableValue, oldValue, newValue) -> { - if (newValue != oldValue) { - runnable.run(); - } - }); - embeddingModel.addListener((observableValue, oldValue, newValue) -> { if (newValue != oldValue) { runnable.run();