Skip to content

Commit

Permalink
Fix for InAnYan#148 and partially InAnYan#146
Browse files Browse the repository at this point in the history
  • Loading branch information
InAnYan committed Aug 14, 2024
1 parent 3c8cb68 commit 5fa3bb5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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;
Expand Down Expand Up @@ -28,6 +30,7 @@
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);
Expand Down Expand Up @@ -70,12 +73,6 @@ public void initialize() {
}
});

scrollPane.needsLayoutProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
scrollPane.setVvalue(1.0);
}
});

chatVBox
.getChildren()
.addAll(aiChatLogic.getChatHistory()
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/jabref/logic/ai/FileEmbeddingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public FileEmbeddingsManager(AiPreferences aiPreferences, ReadOnlyBooleanPropert
}

private void setupListeningToPreferencesChanges() {
aiPreferences.addListenerToEmbeddingsParametersChange(embeddingStore::removeAll);
aiPreferences.addListenerToEmbeddingsParametersChange(() -> {
embeddingStore.removeAll();
fullyIngestedDocumentsTracker.unmarkAll();
});
}

public void addDocument(String link, Document document, long modificationTimeInSeconds, IntegerProperty workDone, IntegerProperty workMax) throws InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ public void unmarkDocumentAsFullyIngested(String link) {
public Set<String> getFullyIngestedDocuments() {
return new HashSet<>(ingestedMap.keySet());
}

public void unmarkAll() {
ingestedMap.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,7 @@ private void setupListeningToPreferencesChanges() {
}
});

aiPreferences.customizeExpertSettingsProperty().addListener((obs, oldValue, newValue) -> {
if (newValue && predictorProperty.get().isEmpty()) {
startRebuildingTask();
}
});

aiPreferences.embeddingModelProperty().addListener(obs -> startRebuildingTask());
aiPreferences.addListenerToEmbeddingsParametersChange(this::startRebuildingTask);
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/jabref/preferences/ai/AiPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ 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();
Expand Down

0 comments on commit 5fa3bb5

Please sign in to comment.