diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index 375ee01a4db..c6466bd19e4 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -14,6 +14,7 @@ import javafx.stage.Stage; import javafx.stage.WindowEvent; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.gui.frame.JabRefFrame; import org.jabref.gui.help.VersionWorker; import org.jabref.gui.icon.IconTheme; @@ -60,6 +61,7 @@ public class JabRefGUI extends Application { // AI Service handles chat messages etc. Therefore, it is tightly coupled to the GUI. private static AiService aiService; + private static ChatHistoryService chatHistoryService; private static StateManager stateManager; private static ThemeManager themeManager; @@ -95,6 +97,7 @@ public void start(Stage stage) { fileUpdateMonitor, preferencesService, aiService, + chatHistoryService, stateManager, countingUndoManager, Injector.instantiateModelOrService(BibEntryTypesManager.class), @@ -164,6 +167,11 @@ public void initialize() { dialogService, taskExecutor); Injector.setModelOrService(AiService.class, aiService); + + JabRefGUI.chatHistoryService = new ChatHistoryService( + preferencesService.getCitationKeyPatternPreferences(), + dialogService); + Injector.setModelOrService(ChatHistoryService.class, chatHistoryService); } private void setupProxy() { diff --git a/src/main/java/org/jabref/gui/entryeditor/AiChatTab.java b/src/main/java/org/jabref/gui/entryeditor/AiChatTab.java index b71a1504942..0fd55ab889f 100644 --- a/src/main/java/org/jabref/gui/entryeditor/AiChatTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/AiChatTab.java @@ -11,6 +11,7 @@ import javafx.scene.control.Tooltip; import org.jabref.gui.DialogService; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.gui.ai.components.aichat.AiChatGuardedComponent; import org.jabref.gui.ai.components.privacynotice.PrivacyNoticeComponent; import org.jabref.gui.ai.components.util.errorstate.ErrorStateComponent; @@ -30,6 +31,7 @@ public class AiChatTab extends EntryEditorTab { private final BibDatabaseContext bibDatabaseContext; private final AiService aiService; + private final ChatHistoryService chatHistoryService; private final DialogService dialogService; private final AiPreferences aiPreferences; private final FilePreferences filePreferences; @@ -41,6 +43,7 @@ public class AiChatTab extends EntryEditorTab { public AiChatTab(BibDatabaseContext bibDatabaseContext, AiService aiService, + ChatHistoryService chatHistoryService, DialogService dialogService, PreferencesService preferencesService, TaskExecutor taskExecutor @@ -48,6 +51,7 @@ public AiChatTab(BibDatabaseContext bibDatabaseContext, this.bibDatabaseContext = bibDatabaseContext; this.aiService = aiService; + this.chatHistoryService = chatHistoryService; this.dialogService = dialogService; this.aiPreferences = preferencesService.getAiPreferences(); @@ -72,9 +76,7 @@ public boolean shouldShow(BibEntry entry) { */ @Override protected void bindToEntry(BibEntry entry) { - previousBibEntry.ifPresent(previousBibEntry -> - aiService.getChatHistoryService().closeChatHistoryForEntry(previousBibEntry)); - + previousBibEntry.ifPresent(previousBibEntry -> chatHistoryService.closeChatHistoryForEntry(previousBibEntry)); previousBibEntry = Optional.of(entry); if (!aiPreferences.getEnableAi()) { @@ -133,7 +135,7 @@ private void bindToCorrectEntry(BibEntry entry) { setContent(new AiChatGuardedComponent( chatName, - aiService.getChatHistoryService().getChatHistoryForEntry(entry), + chatHistoryService.getChatHistoryForEntry(entry), bibDatabaseContext, FXCollections.observableArrayList(new ArrayList<>(List.of(entry))), aiService, diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 469a111273b..b27a260d77a 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -30,6 +30,7 @@ import org.jabref.gui.DialogService; import org.jabref.gui.LibraryTab; import org.jabref.gui.StateManager; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.gui.citationkeypattern.GenerateCitationKeySingleAction; import org.jabref.gui.cleanup.CleanupSingleAction; import org.jabref.gui.entryeditor.citationrelationtab.CitationRelationsTab; @@ -118,6 +119,7 @@ public class EntryEditor extends BorderPane { @Inject private KeyBindingRepository keyBindingRepository; @Inject private JournalAbbreviationRepository journalAbbreviationRepository; @Inject private AiService aiService; + @Inject private ChatHistoryService chatHistoryService; private final List allPossibleTabs; private final Collection previewTabs; @@ -313,7 +315,7 @@ private List createTabs() { tabs.add(new LatexCitationsTab(databaseContext, preferencesService, dialogService, directoryMonitorManager)); tabs.add(new FulltextSearchResultsTab(stateManager, preferencesService, dialogService, databaseContext, taskExecutor, libraryTab.searchQueryProperty())); tabs.add(new AiSummaryTab(libraryTab.getBibDatabaseContext(), aiService, dialogService, preferencesService)); - tabs.add(new AiChatTab(libraryTab.getBibDatabaseContext(), aiService, dialogService, preferencesService, taskExecutor)); + tabs.add(new AiChatTab(libraryTab.getBibDatabaseContext(), aiService, chatHistoryService, dialogService, preferencesService, taskExecutor)); return tabs; } diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index af2feeedc0c..349746c82fd 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -33,6 +33,7 @@ import org.jabref.gui.actions.ActionHelper; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.actions.StandardActions; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.gui.desktop.JabRefDesktop; import org.jabref.gui.importer.NewEntryAction; import org.jabref.gui.importer.actions.OpenDatabaseAction; @@ -76,6 +77,7 @@ public class JabRefFrame extends BorderPane implements LibraryTabContainer, UiMe private final SplitPane splitPane = new SplitPane(); private final PreferencesService prefs; private final AiService aiService; + private final ChatHistoryService chatHistoryService; private final GlobalSearchBar globalSearchBar; private final FileHistoryMenu fileHistory; @@ -104,6 +106,7 @@ public JabRefFrame(Stage mainStage, FileUpdateMonitor fileUpdateMonitor, PreferencesService preferencesService, AiService aiService, + ChatHistoryService chatHistoryService, StateManager stateManager, CountingUndoManager undoManager, BibEntryTypesManager entryTypesManager, @@ -114,6 +117,7 @@ public JabRefFrame(Stage mainStage, this.fileUpdateMonitor = fileUpdateMonitor; this.prefs = preferencesService; this.aiService = aiService; + this.chatHistoryService = chatHistoryService; this.stateManager = stateManager; this.undoManager = undoManager; this.entryTypesManager = entryTypesManager; @@ -153,7 +157,7 @@ public JabRefFrame(Stage mainStage, this.sidePane = new SidePane( this, prefs, - aiService, + chatHistoryService, Injector.instantiateModelOrService(JournalAbbreviationRepository.class), taskExecutor, dialogService, diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 139e47df2e7..909c0bf734b 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -50,6 +50,7 @@ import org.jabref.gui.actions.ActionFactory; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.actions.StandardActions; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.gui.search.SearchTextField; import org.jabref.gui.util.BindingsHelper; import org.jabref.gui.util.ControlHelper; @@ -57,7 +58,6 @@ import org.jabref.gui.util.RecursiveTreeItem; import org.jabref.gui.util.ViewModelTreeTableCellFactory; import org.jabref.gui.util.ViewModelTreeTableRowFactory; -import org.jabref.logic.ai.AiService; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.TaskExecutor; import org.jabref.model.entry.BibEntry; @@ -82,7 +82,7 @@ public class GroupTreeView extends BorderPane { private final StateManager stateManager; private final DialogService dialogService; - private final AiService aiService; + private final ChatHistoryService chatHistoryService; private final TaskExecutor taskExecutor; private final PreferencesService preferencesService; @@ -108,13 +108,13 @@ public GroupTreeView(TaskExecutor taskExecutor, StateManager stateManager, PreferencesService preferencesService, DialogService dialogService, - AiService aiService + ChatHistoryService chatHistoryService ) { this.taskExecutor = taskExecutor; this.stateManager = stateManager; this.preferencesService = preferencesService; this.dialogService = dialogService; - this.aiService = aiService; + this.chatHistoryService = chatHistoryService; createNodes(); this.getStylesheets().add(Objects.requireNonNull(GroupTreeView.class.getResource("GroupTree.css")).toExternalForm()); @@ -164,7 +164,7 @@ private void createNodes() { private void initialize() { this.localDragboard = stateManager.getLocalDragboard(); - viewModel = new GroupTreeViewModel(stateManager, dialogService, aiService, preferencesService, taskExecutor, localDragboard); + viewModel = new GroupTreeViewModel(stateManager, dialogService, chatHistoryService, preferencesService, taskExecutor, localDragboard); // Set-up groups tree groupTree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index b21826d6acf..bac654cfb59 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -24,6 +24,7 @@ import org.jabref.gui.AbstractViewModel; import org.jabref.gui.DialogService; import org.jabref.gui.StateManager; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.gui.ai.components.aichat.AiChatWindow; import org.jabref.gui.util.CustomLocalDragboard; import org.jabref.logic.ai.AiService; @@ -53,7 +54,7 @@ public class GroupTreeViewModel extends AbstractViewModel { private final ListProperty selectedGroups = new SimpleListProperty<>(FXCollections.observableArrayList()); private final StateManager stateManager; private final DialogService dialogService; - private final AiService aiService; + private final ChatHistoryService chatHistoryService; private final PreferencesService preferences; private final TaskExecutor taskExecutor; private final CustomLocalDragboard localDragboard; @@ -77,10 +78,10 @@ public class GroupTreeViewModel extends AbstractViewModel { }; private Optional currentDatabase = Optional.empty(); - public GroupTreeViewModel(StateManager stateManager, DialogService dialogService, AiService aiService, PreferencesService preferencesService, TaskExecutor taskExecutor, CustomLocalDragboard localDragboard) { + public GroupTreeViewModel(StateManager stateManager, DialogService dialogService, ChatHistoryService chatHistoryService, PreferencesService preferencesService, TaskExecutor taskExecutor, CustomLocalDragboard localDragboard) { this.stateManager = Objects.requireNonNull(stateManager); this.dialogService = Objects.requireNonNull(dialogService); - this.aiService = Objects.requireNonNull(aiService); + this.chatHistoryService = Objects.requireNonNull(chatHistoryService); this.preferences = Objects.requireNonNull(preferencesService); this.taskExecutor = Objects.requireNonNull(taskExecutor); this.localDragboard = Objects.requireNonNull(localDragboard); @@ -398,7 +399,7 @@ public void chatWithGroup(GroupNodeViewModel group) { StringProperty nameProperty = new SimpleStringProperty(Localization.lang("Group %0", groupNameProperty.get())); groupNameProperty.addListener((obs, oldValue, newValue) -> nameProperty.setValue(Localization.lang("Group %0", groupNameProperty.get()))); - ObservableList chatHistory = aiService.getChatHistoryService().getChatHistoryForGroup(group.getGroupNode()); + ObservableList chatHistory = chatHistoryService.getChatHistoryForGroup(group.getGroupNode()); ObservableList bibEntries = FXCollections.observableArrayList(group.getGroupNode().findMatches(currentDatabase.get().getDatabase())); openAiChat(nameProperty, chatHistory, currentDatabase.get(), bibEntries); diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 8690dc0db8f..3d31d1bf3b6 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -35,12 +35,10 @@ import org.jabref.gui.actions.StandardActions; import org.jabref.gui.help.HelpAction; import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableKeyChange; import org.jabref.gui.util.DirectoryDialogConfiguration; import org.jabref.gui.util.UiTaskExecutor; -import org.jabref.logic.ai.AiService; import org.jabref.logic.citationkeypattern.CitationKeyGenerator; import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences; import org.jabref.logic.citationstyle.CitationStyle; @@ -95,7 +93,6 @@ public class OpenOfficePanel { private final VBox vbox = new VBox(); private final PreferencesService preferencesService; - private final AiService aiService; private final StateManager stateManager; private final ClipBoardManager clipBoardManager; private final UndoManager undoManager; @@ -109,8 +106,6 @@ public class OpenOfficePanel { public OpenOfficePanel(LibraryTabContainer tabContainer, PreferencesService preferencesService, - AiService aiService, - KeyBindingRepository keyBindingRepository, JournalAbbreviationRepository abbreviationRepository, UiTaskExecutor taskExecutor, DialogService dialogService, @@ -123,7 +118,6 @@ public OpenOfficePanel(LibraryTabContainer tabContainer, this.fileUpdateMonitor = fileUpdateMonitor; this.entryTypesManager = entryTypesManager; this.preferencesService = preferencesService; - this.aiService = aiService; this.taskExecutor = taskExecutor; this.dialogService = dialogService; this.stateManager = stateManager; diff --git a/src/main/java/org/jabref/gui/sidepane/SidePane.java b/src/main/java/org/jabref/gui/sidepane/SidePane.java index aaa7696e043..01892613e79 100644 --- a/src/main/java/org/jabref/gui/sidepane/SidePane.java +++ b/src/main/java/org/jabref/gui/sidepane/SidePane.java @@ -15,7 +15,7 @@ import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.logic.ai.AiService; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.util.TaskExecutor; import org.jabref.model.entry.BibEntryTypesManager; @@ -33,7 +33,7 @@ public class SidePane extends VBox { public SidePane(LibraryTabContainer tabContainer, PreferencesService preferencesService, - AiService aiService, + ChatHistoryService chatHistoryService, JournalAbbreviationRepository abbreviationRepository, TaskExecutor taskExecutor, DialogService dialogService, @@ -47,7 +47,7 @@ public SidePane(LibraryTabContainer tabContainer, this.viewModel = new SidePaneViewModel( tabContainer, preferencesService, - aiService, + chatHistoryService, abbreviationRepository, stateManager, taskExecutor, diff --git a/src/main/java/org/jabref/gui/sidepane/SidePaneContentFactory.java b/src/main/java/org/jabref/gui/sidepane/SidePaneContentFactory.java index 0f7d4f4fc8c..4a9e680c584 100644 --- a/src/main/java/org/jabref/gui/sidepane/SidePaneContentFactory.java +++ b/src/main/java/org/jabref/gui/sidepane/SidePaneContentFactory.java @@ -8,11 +8,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.gui.groups.GroupTreeView; import org.jabref.gui.importer.fetcher.WebSearchPaneView; import org.jabref.gui.openoffice.OpenOfficePanel; import org.jabref.gui.util.UiTaskExecutor; -import org.jabref.logic.ai.AiService; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.util.TaskExecutor; import org.jabref.model.entry.BibEntryTypesManager; @@ -22,7 +22,7 @@ public class SidePaneContentFactory { private final LibraryTabContainer tabContainer; private final PreferencesService preferences; - private final AiService aiService; + private final ChatHistoryService chatHistoryService; private final JournalAbbreviationRepository abbreviationRepository; private final TaskExecutor taskExecutor; private final DialogService dialogService; @@ -34,7 +34,7 @@ public class SidePaneContentFactory { public SidePaneContentFactory(LibraryTabContainer tabContainer, PreferencesService preferences, - AiService aiService, + ChatHistoryService chatHistoryService, JournalAbbreviationRepository abbreviationRepository, TaskExecutor taskExecutor, DialogService dialogService, @@ -45,7 +45,7 @@ public SidePaneContentFactory(LibraryTabContainer tabContainer, UndoManager undoManager) { this.tabContainer = tabContainer; this.preferences = preferences; - this.aiService = aiService; + this.chatHistoryService = chatHistoryService; this.abbreviationRepository = abbreviationRepository; this.taskExecutor = taskExecutor; this.dialogService = dialogService; @@ -63,12 +63,10 @@ public Node create(SidePaneType sidePaneType) { stateManager, preferences, dialogService, - aiService); + chatHistoryService); case OPEN_OFFICE -> new OpenOfficePanel( tabContainer, preferences, - aiService, - preferences.getKeyBindingRepository(), abbreviationRepository, (UiTaskExecutor) taskExecutor, dialogService, diff --git a/src/main/java/org/jabref/gui/sidepane/SidePaneViewModel.java b/src/main/java/org/jabref/gui/sidepane/SidePaneViewModel.java index eb938e06acf..c7a716d97c8 100644 --- a/src/main/java/org/jabref/gui/sidepane/SidePaneViewModel.java +++ b/src/main/java/org/jabref/gui/sidepane/SidePaneViewModel.java @@ -19,7 +19,7 @@ import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; import org.jabref.gui.actions.SimpleCommand; -import org.jabref.logic.ai.AiService; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.util.TaskExecutor; import org.jabref.model.entry.BibEntryTypesManager; @@ -42,7 +42,7 @@ public class SidePaneViewModel extends AbstractViewModel { public SidePaneViewModel(LibraryTabContainer tabContainer, PreferencesService preferencesService, - AiService aiService, + ChatHistoryService chatHistoryService, JournalAbbreviationRepository abbreviationRepository, StateManager stateManager, TaskExecutor taskExecutor, @@ -57,7 +57,7 @@ public SidePaneViewModel(LibraryTabContainer tabContainer, this.sidePaneContentFactory = new SidePaneContentFactory( tabContainer, preferencesService, - aiService, + chatHistoryService, abbreviationRepository, taskExecutor, dialogService, diff --git a/src/main/java/org/jabref/logic/ai/AiService.java b/src/main/java/org/jabref/logic/ai/AiService.java index 6e06d76ff1f..c89620d6694 100644 --- a/src/main/java/org/jabref/logic/ai/AiService.java +++ b/src/main/java/org/jabref/logic/ai/AiService.java @@ -7,8 +7,6 @@ import javafx.beans.property.SimpleBooleanProperty; import org.jabref.logic.ai.chatting.AiChatService; -import org.jabref.logic.ai.chatting.chathistory.ChatHistoryService; -import org.jabref.logic.ai.chatting.chathistory.storages.MVStoreChatHistoryStorage; import org.jabref.logic.ai.chatting.model.JabRefChatLanguageModel; import org.jabref.logic.ai.ingestion.IngestionService; import org.jabref.logic.ai.ingestion.MVStoreEmbeddingStore; @@ -33,7 +31,6 @@ public class AiService implements AutoCloseable { public static final String VERSION = "1"; - private static final String CHAT_HISTORY_FILE_NAME = "chat-histories.mv"; private static final String EMBEDDINGS_FILE_NAME = "embeddings.mv"; private static final String FULLY_INGESTED_FILE_NAME = "fully-ingested.mv"; private static final String SUMMARIES_FILE_NAME = "summaries.mv"; @@ -49,11 +46,9 @@ public class AiService implements AutoCloseable { private final MVStoreEmbeddingStore mvStoreEmbeddingStore; private final MVStoreFullyIngestedDocumentsTracker mvStoreFullyIngestedDocumentsTracker; - private final MVStoreChatHistoryStorage mvStoreChatHistoryStorage; private final MVStoreSummariesStorage mvStoreSummariesStorage; private final JabRefChatLanguageModel jabRefChatLanguageModel; - private final ChatHistoryService chatHistoryService; private final JabRefEmbeddingModel jabRefEmbeddingModel; private final AiChatService aiChatService; private final IngestionService ingestionService; @@ -70,9 +65,7 @@ public AiService(AiPreferences aiPreferences, this.mvStoreEmbeddingStore = new MVStoreEmbeddingStore(Directories.getAiFilesDirectory().resolve(EMBEDDINGS_FILE_NAME), notificationService); this.mvStoreFullyIngestedDocumentsTracker = new MVStoreFullyIngestedDocumentsTracker(Directories.getAiFilesDirectory().resolve(FULLY_INGESTED_FILE_NAME), notificationService); this.mvStoreSummariesStorage = new MVStoreSummariesStorage(Directories.getAiFilesDirectory().resolve(SUMMARIES_FILE_NAME), notificationService); - this.mvStoreChatHistoryStorage = new MVStoreChatHistoryStorage(Directories.getAiFilesDirectory().resolve(CHAT_HISTORY_FILE_NAME), notificationService); - this.chatHistoryService = new ChatHistoryService(citationKeyPatternPreferences, mvStoreChatHistoryStorage); this.jabRefEmbeddingModel = new JabRefEmbeddingModel(aiPreferences, notificationService, taskExecutor); this.aiChatService = new AiChatService(aiPreferences, jabRefChatLanguageModel, jabRefEmbeddingModel, mvStoreEmbeddingStore, cachedThreadPool); this.ingestionService = new IngestionService( @@ -99,10 +92,6 @@ public AiChatService getAiChatService() { return aiChatService; } - public ChatHistoryService getChatHistoryService() { - return chatHistoryService; - } - public IngestionService getIngestionService() { return ingestionService; } @@ -118,11 +107,9 @@ public void close() { cachedThreadPool.shutdownNow(); jabRefChatLanguageModel.close(); jabRefEmbeddingModel.close(); - chatHistoryService.close(); mvStoreFullyIngestedDocumentsTracker.close(); mvStoreEmbeddingStore.close(); - mvStoreChatHistoryStorage.close(); mvStoreSummariesStorage.close(); } } diff --git a/src/test/java/org/jabref/gui/groups/GroupTreeViewModelTest.java b/src/test/java/org/jabref/gui/groups/GroupTreeViewModelTest.java index 2c96bb07840..7104f1ecedd 100644 --- a/src/test/java/org/jabref/gui/groups/GroupTreeViewModelTest.java +++ b/src/test/java/org/jabref/gui/groups/GroupTreeViewModelTest.java @@ -5,10 +5,10 @@ import org.jabref.gui.DialogService; import org.jabref.gui.StateManager; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.gui.util.CustomLocalDragboard; -import org.jabref.logic.util.TaskExecutor; -import org.jabref.logic.ai.AiService; import org.jabref.logic.util.CurrentThreadTaskExecutor; +import org.jabref.logic.util.TaskExecutor; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; @@ -52,7 +52,7 @@ void setUp() { true, true, GroupHierarchyType.INDEPENDENT)); - groupTree = new GroupTreeViewModel(stateManager, mock(DialogService.class), mock(AiService.class), preferencesService, taskExecutor, new CustomLocalDragboard()); + groupTree = new GroupTreeViewModel(stateManager, mock(DialogService.class), mock(ChatHistoryService.class), preferencesService, taskExecutor, new CustomLocalDragboard()); } @Test @@ -100,7 +100,7 @@ void shouldNotShowDialogWhenGroupNameChanges() { BibEntry entry = new BibEntry(); databaseContext.getDatabase().insertEntry(entry); - GroupTreeViewModel model = new GroupTreeViewModel(stateManager, dialogService, mock(AiService.class), preferencesService, taskExecutor, new CustomLocalDragboard()); + GroupTreeViewModel model = new GroupTreeViewModel(stateManager, dialogService, mock(ChatHistoryService.class), preferencesService, taskExecutor, new CustomLocalDragboard()); assertTrue(model.onlyMinorChanges(oldGroup, newGroup)); } @@ -112,7 +112,7 @@ void shouldNotShowDialogWhenGroupsAreEqual() { BibEntry entry = new BibEntry(); databaseContext.getDatabase().insertEntry(entry); - GroupTreeViewModel model = new GroupTreeViewModel(stateManager, dialogService, mock(AiService.class), preferencesService, taskExecutor, new CustomLocalDragboard()); + GroupTreeViewModel model = new GroupTreeViewModel(stateManager, dialogService, mock(ChatHistoryService.class), preferencesService, taskExecutor, new CustomLocalDragboard()); assertTrue(model.onlyMinorChanges(oldGroup, newGroup)); } @@ -124,7 +124,7 @@ void shouldShowDialogWhenKeywordDiffers() { BibEntry entry = new BibEntry(); databaseContext.getDatabase().insertEntry(entry); - GroupTreeViewModel model = new GroupTreeViewModel(stateManager, dialogService, mock(AiService.class), preferencesService, taskExecutor, new CustomLocalDragboard()); + GroupTreeViewModel model = new GroupTreeViewModel(stateManager, dialogService, mock(ChatHistoryService.class), preferencesService, taskExecutor, new CustomLocalDragboard()); assertFalse(model.onlyMinorChanges(oldGroup, newGroup)); } @@ -136,7 +136,7 @@ void shouldShowDialogWhenCaseSensitivyDiffers() { BibEntry entry = new BibEntry(); databaseContext.getDatabase().insertEntry(entry); - GroupTreeViewModel model = new GroupTreeViewModel(stateManager, dialogService, mock(AiService.class), preferencesService, taskExecutor, new CustomLocalDragboard()); + GroupTreeViewModel model = new GroupTreeViewModel(stateManager, dialogService, mock(ChatHistoryService.class), preferencesService, taskExecutor, new CustomLocalDragboard()); assertFalse(model.onlyMinorChanges(oldGroup, newGroup)); } } diff --git a/src/test/java/org/jabref/gui/sidepane/SidePaneViewModelTest.java b/src/test/java/org/jabref/gui/sidepane/SidePaneViewModelTest.java index bb293745c60..0d0e997a250 100644 --- a/src/test/java/org/jabref/gui/sidepane/SidePaneViewModelTest.java +++ b/src/test/java/org/jabref/gui/sidepane/SidePaneViewModelTest.java @@ -13,11 +13,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.LibraryTabContainer; import org.jabref.gui.StateManager; +import org.jabref.gui.ai.chatting.chathistory.ChatHistoryService; import org.jabref.gui.util.CustomLocalDragboard; import org.jabref.gui.util.OptionalObjectProperty; -import org.jabref.logic.util.TaskExecutor; -import org.jabref.logic.ai.AiService; import org.jabref.logic.journals.JournalAbbreviationRepository; +import org.jabref.logic.util.TaskExecutor; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.model.util.FileUpdateMonitor; import org.jabref.preferences.PreferencesService; @@ -38,7 +38,7 @@ class SidePaneViewModelTest { LibraryTabContainer tabContainer = mock(LibraryTabContainer.class); PreferencesService preferencesService = mock(PreferencesService.class); - AiService aiService = mock(AiService.class); + ChatHistoryService chatHistoryService = mock(ChatHistoryService.class); JournalAbbreviationRepository abbreviationRepository = mock(JournalAbbreviationRepository.class); StateManager stateManager = mock(StateManager.class); TaskExecutor taskExecutor = mock(TaskExecutor.class); @@ -67,7 +67,7 @@ void setUp() { sidePaneViewModel = new SidePaneViewModel( tabContainer, preferencesService, - aiService, + chatHistoryService, abbreviationRepository, stateManager, taskExecutor,