From 709386ad1700ee6ce59864d630be047f4b515d88 Mon Sep 17 00:00:00 2001 From: Ruslan Date: Wed, 30 Oct 2024 11:12:21 +0200 Subject: [PATCH] Customizable AI templates (#11884) * Start to work * Fix runtime problems and checkers * Merge with main * Fix from code review * Update from merge * Fix compiler errors * Fix from code review --- build.gradle | 2 +- src/main/java/module-info.java | 1 + .../org/jabref/gui/preferences/ai/AiTab.fxml | 39 ++++- .../org/jabref/gui/preferences/ai/AiTab.java | 29 ++-- .../gui/preferences/ai/AiTabViewModel.java | 42 +++--- .../jabref/logic/ai/AiDefaultPreferences.java | 41 ++++++ .../org/jabref/logic/ai/AiPreferences.java | 26 +++- .../java/org/jabref/logic/ai/AiService.java | 5 +- .../jabref/logic/ai/chatting/AiChatLogic.java | 136 ++++++++++-------- .../logic/ai/chatting/AiChatService.java | 11 +- .../GenerateSummaryForSeveralTask.java | 5 + .../ai/summarization/GenerateSummaryTask.java | 50 ++----- .../ai/summarization/SummariesService.java | 8 +- .../jabref/logic/ai/templates/AiTemplate.java | 30 ++++ .../logic/ai/templates/PaperExcerpt.java | 3 + .../logic/ai/templates/TemplatesService.java | 62 ++++++++ .../java/org/jabref/logic/help/HelpFile.java | 3 +- .../preferences/JabRefCliPreferences.java | 27 +++- src/main/resources/l10n/JabRef_en.properties | 7 +- 19 files changed, 386 insertions(+), 141 deletions(-) create mode 100644 src/main/java/org/jabref/logic/ai/templates/AiTemplate.java create mode 100644 src/main/java/org/jabref/logic/ai/templates/PaperExcerpt.java create mode 100644 src/main/java/org/jabref/logic/ai/templates/TemplatesService.java diff --git a/build.gradle b/build.gradle index 5a364835b36..b71603a1056 100644 --- a/build.gradle +++ b/build.gradle @@ -351,7 +351,7 @@ dependencies { exclude group: 'org.jetbrains.kotlin' } - + implementation 'org.apache.velocity:velocity-engine-core:2.3' implementation platform('ai.djl:bom:0.30.0') implementation 'ai.djl:api' implementation 'ai.djl.huggingface:tokenizers' diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 49906ad2625..f0151b8988e 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -160,6 +160,7 @@ uses ai.djl.repository.RepositoryFactory; uses ai.djl.repository.zoo.ZooProvider; uses dev.langchain4j.spi.prompt.PromptTemplateFactory; + requires velocity.engine.core; // endregion // region: Lucene diff --git a/src/main/java/org/jabref/gui/preferences/ai/AiTab.fxml b/src/main/java/org/jabref/gui/preferences/ai/AiTab.fxml index b81bd96ba06..64e737747f5 100644 --- a/src/main/java/org/jabref/gui/preferences/ai/AiTab.fxml +++ b/src/main/java/org/jabref/gui/preferences/ai/AiTab.fxml @@ -16,6 +16,9 @@ + + + - - @@ -235,5 +234,37 @@ glyph="REFRESH"/> + + +