Skip to content

Commit

Permalink
Merge branch 'main' into LuceneSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
LoayGhreeb committed Aug 25, 2024
2 parents 4ca8afb + f6ea6a9 commit 9ca71c7
Show file tree
Hide file tree
Showing 15 changed files with 1,312 additions and 322 deletions.
314 changes: 206 additions & 108 deletions src/main/java/org/jabref/gui/preferences/ai/AiTab.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -9,151 +9,249 @@

<?import org.jabref.gui.icon.JabRefIconView?>
<?import org.controlsfx.control.SearchableComboBox?>
<fx:root spacing="10.0" type="VBox" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.preferences.ai.AiTab">

<?import com.dlsc.gemsfx.ResizableTextArea?>
<fx:root
spacing="10.0"
type="VBox"
xmlns="http://javafx.com/javafx/17.0.2-ea"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.jabref.gui.preferences.ai.AiTab">
<children>
<Label styleClass="titleHeader" text="%AI" />
<Label styleClass="titleHeader"
text="%AI"/>

<Label styleClass="sectionHeader" text="%General" />
<Label styleClass="sectionHeader"
text="%General"/>

<HBox alignment="CENTER_LEFT" spacing="10.0">
<HBox alignment="CENTER_LEFT"
spacing="10.0">
<children>
<CheckBox fx:id="enableAi" mnemonicParsing="false" text="%Enable AI functionality (summary generation and chatting) in JabRef" VBox.vgrow="ALWAYS" />
<Button fx:id="enableAiHelp" prefWidth="20.0" />
<CheckBox
fx:id="enableAi"
mnemonicParsing="false"
text="%Enable AI functionality (summary generation and chatting) in JabRef"
HBox.hgrow="ALWAYS"
maxWidth="Infinity"/>
<Button fx:id="enableAiHelp"
prefWidth="20.0"/>
</children>
</HBox>

<HBox alignment="CENTER_LEFT" layoutX="10.0" layoutY="306.0" spacing="10.0">
<HBox alignment="CENTER_LEFT"
layoutX="10.0"
layoutY="306.0"
spacing="10.0">
<children>
<Label alignment="BASELINE_CENTER" text="%AI provider" />
<ComboBox fx:id="aiProviderComboBox" maxWidth="1.7976931348623157E308" HBox.hgrow="ALWAYS" />
<Button fx:id="aiProviderHelp" prefWidth="20.0" />
<Label alignment="BASELINE_CENTER"
text="%AI provider"/>
<ComboBox
fx:id="aiProviderComboBox"
maxWidth="1.7976931348623157E308"
HBox.hgrow="ALWAYS"/>
<Button fx:id="aiProviderHelp"
prefWidth="20.0"/>
</children>
</HBox>

<HBox alignment="CENTER_LEFT" spacing="10.0">
<HBox alignment="CENTER_LEFT"
spacing="10.0">
<children>
<Label alignment="BASELINE_CENTER" text="%Chat model" />
<ComboBox fx:id="chatModelComboBox" editable="true" maxWidth="1.7976931348623157E308" HBox.hgrow="ALWAYS" />
<Button fx:id="chatModelHelp" prefWidth="20.0" />
<Label alignment="BASELINE_CENTER"
text="%Chat model"/>
<ComboBox
fx:id="chatModelComboBox"
editable="true"
maxWidth="1.7976931348623157E308"
HBox.hgrow="ALWAYS"/>
<Button fx:id="chatModelHelp"
prefWidth="20.0"/>
</children>
<padding>
<Insets left="20.0" />
<Insets left="20.0"/>
</padding>
</HBox>

<HBox alignment="CENTER_LEFT" spacing="10.0">
<HBox alignment="CENTER_LEFT"
spacing="10.0">
<children>
<Label alignment="BASELINE_CENTER" text="%API key" />
<CustomPasswordField fx:id="apiKeyTextField" HBox.hgrow="ALWAYS" />
<Button fx:id="apiKeyHelp" prefWidth="20.0" />
<Label alignment="BASELINE_CENTER"
text="%API key"/>
<CustomPasswordField
fx:id="apiKeyTextField"
HBox.hgrow="ALWAYS"/>
<Button fx:id="apiKeyHelp"
prefWidth="20.0"/>
</children>
<padding>
<Insets left="20.0" />
<Insets left="20.0"/>
</padding>
</HBox>

<Label styleClass="sectionHeader" text="%Expert settings" />
<Label styleClass="sectionHeader"
text="%Expert settings"/>
<VBox>
<children>
<Label text="%These parameters affect how the AI will answer your questions." />
<Label text="%Leave these fields as is, if you are not sure of their purpose." />
<Label text="%These parameters affect how the AI will answer your questions."/>
<Label text="%Leave these fields as is, if you are not sure of their purpose."/>
</children>
</VBox>

<CheckBox fx:id="customizeExpertSettingsCheckbox" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="%Customize expert settings" />
<CheckBox
fx:id="customizeExpertSettingsCheckbox"
maxWidth="1.7976931348623157E308"
mnemonicParsing="false"
text="%Customize expert settings"/>

<HBox alignment="CENTER_LEFT" spacing="10.0">
<HBox alignment="CENTER_LEFT"
spacing="10.0">
<children>
<Label alignment="BASELINE_CENTER" text="%API base URL (used only for LLM)" />
<TextField fx:id="apiBaseUrlTextField" disable="true" maxWidth="1.7976931348623157E308" HBox.hgrow="ALWAYS" />
<Button fx:id="apiBaseUrlHelp" prefWidth="20.0" />
<Label alignment="BASELINE_CENTER"
text="%API base URL (used only for LLM)"/>
<TextField
fx:id="apiBaseUrlTextField"
disable="true"
maxWidth="1.7976931348623157E308"
HBox.hgrow="ALWAYS"/>
<Button fx:id="apiBaseUrlHelp"
prefWidth="20.0"/>
</children>
</HBox>


<HBox alignment="CENTER_LEFT" spacing="10.0">
<HBox alignment="CENTER_LEFT"
spacing="10.0">
<children>
<Label alignment="BASELINE_CENTER" text="%Embedding model" />
<SearchableComboBox fx:id="embeddingModelComboBox" maxWidth="1.7976931348623157E308" HBox.hgrow="ALWAYS" />
<Button fx:id="embeddingModelHelp" prefWidth="20.0" />
<Label alignment="BASELINE_CENTER"
text="%Embedding model"/>
<SearchableComboBox
fx:id="embeddingModelComboBox"
maxWidth="1.7976931348623157E308"
HBox.hgrow="ALWAYS"/>
<Button fx:id="embeddingModelHelp"
prefWidth="20.0"/>
</children>
</HBox>

<Label text="%The size of the embedding model could be smaller than written in the list.">
<font>
<Font name="System Italic" size="13.0" />
</font></Label>

<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<Label maxWidth="1.7976931348623157E308" text="%Instruction for AI (also known as prompt or system message)" HBox.hgrow="ALWAYS" />
<Button fx:id="instructionHelp" prefWidth="20.0" />
</children>
</HBox>

<TextArea fx:id="instructionTextArea" wrapText="true" />

<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<Label alignment="BASELINE_CENTER" text="%Context window size" />
<IntegerInputField fx:id="contextWindowSizeTextField" HBox.hgrow="ALWAYS" />
<Button fx:id="contextWindowSizeHelp" prefWidth="20.0" />
</children>
</HBox>
<HBox alignment="CENTER_LEFT" layoutX="10.0" layoutY="448.0" spacing="10.0">
<children>
<Label alignment="BASELINE_CENTER" text="%Temperature" />
<DoubleInputField fx:id="temperatureTextField" HBox.hgrow="ALWAYS" />
</children>
</HBox>
<VBox>
<children>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<Label maxWidth="1.7976931348623157E308" text="%RAG - maximum results count" HBox.hgrow="ALWAYS" />
<Button fx:id="ragMaxResultsCountHelp" prefWidth="20.0" />
</children>
</HBox>
<IntegerInputField fx:id="ragMaxResultsCountTextField" />
</children>
</VBox>
<VBox>
<children>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<Label maxWidth="1.7976931348623157E308" text="%RAG - minimum score" HBox.hgrow="ALWAYS" />
<Button fx:id="ragMinScoreHelp" prefWidth="20.0" />
</children>
</HBox>
<DoubleInputField fx:id="ragMinScoreTextField" />
</children>
</VBox>
<VBox>
<children>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<Label maxWidth="1.7976931348623157E308" text="%Document splitter - chunk size" HBox.hgrow="ALWAYS" />
<Button fx:id="documentSplitterChunkSizeHelp" prefWidth="20.0" />
</children>
</HBox>
<IntegerInputField fx:id="documentSplitterChunkSizeTextField" />
</children>
</VBox>
<VBox>
<children>
<HBox alignment="CENTER_LEFT" spacing="10.0">
<children>
<Label maxWidth="1.7976931348623157E308" text="%Document splitter - overlap size" HBox.hgrow="ALWAYS" />
<Button fx:id="documentSplitterOverlapSizeHelp" prefWidth="20.0" />
</children>
</HBox>
<IntegerInputField fx:id="documentSplitterOverlapSizeTextField" />
</children>
</VBox>
<Button onAction="#onResetExpertSettingsButtonClick" text="%Reset expert settings to default">
<graphic>
<JabRefIconView glyph="REFRESH"/>
</graphic>
</Button>
<font>
<Font name="System Italic"
size="13.0"/>
</font>
</Label>

<HBox alignment="CENTER_LEFT"
spacing="10.0">
<children>
<Label maxWidth="1.7976931348623157E308"
text="%Instruction for AI (also known as prompt or system message)"
HBox.hgrow="ALWAYS"/>
<Button fx:id="instructionHelp"
prefWidth="20.0"/>
</children>
</HBox>

<ResizableTextArea
fx:id="instructionTextArea"
wrapText="true"/>

<GridPane hgap="10" vgap="10">
<columnConstraints>
<ColumnConstraints hgrow="ALWAYS" percentWidth="50" />
<ColumnConstraints hgrow="ALWAYS" percentWidth="50" />
</columnConstraints>

<!-- Context Window Size -->
<VBox spacing="10" GridPane.columnIndex="0" GridPane.rowIndex="0">
<HBox spacing="10" alignment="CENTER_LEFT">
<Label HBox.hgrow="ALWAYS"
maxWidth="Infinity"
text="%Context window size"/>
<Button fx:id="contextWindowSizeHelp"
prefWidth="20.0"/>
</HBox>
<IntegerInputField
fx:id="contextWindowSizeTextField"
HBox.hgrow="ALWAYS"/>
</VBox>

<!-- Temperature -->
<VBox spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="0">
<HBox spacing="10">
<Label HBox.hgrow="ALWAYS"
maxWidth="Infinity"
text="%Temperature"/>
<Button fx:id="temperatureHelp"
prefWidth="20.0"/>
</HBox>
<DoubleInputField
fx:id="temperatureTextField"
HBox.hgrow="ALWAYS"/>
</VBox>

<!-- RAG - Maximum Results Count -->
<VBox spacing="10" GridPane.columnIndex="0" GridPane.rowIndex="1">
<HBox spacing="10" alignment="CENTER_LEFT">
<Label HBox.hgrow="ALWAYS"
maxWidth="Infinity"
text="%RAG - maximum results count"/>
<Button fx:id="ragMaxResultsCountHelp"
prefWidth="20.0"/>
</HBox>
<IntegerInputField
fx:id="ragMaxResultsCountTextField"
HBox.hgrow="ALWAYS"/>
</VBox>

<!-- RAG - Minimum Score -->
<VBox spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="1">
<HBox spacing="10" alignment="CENTER_LEFT">
<Label HBox.hgrow="ALWAYS"
maxWidth="Infinity"
text="%RAG - minimum score"/>
<Button fx:id="ragMinScoreHelp"
prefWidth="20.0"/>
</HBox>
<DoubleInputField
fx:id="ragMinScoreTextField"
HBox.hgrow="ALWAYS"/>
</VBox>

<!-- Document Splitter - Chunk Size -->
<VBox spacing="10" GridPane.columnIndex="0" GridPane.rowIndex="2">
<HBox spacing="10" alignment="CENTER_LEFT">
<Label HBox.hgrow="ALWAYS"
maxWidth="Infinity"
text="%Document splitter - chunk size"/>
<Button fx:id="documentSplitterChunkSizeHelp"
prefWidth="20.0"/>
</HBox>
<IntegerInputField
fx:id="documentSplitterChunkSizeTextField"
HBox.hgrow="ALWAYS"/>
</VBox>

<!-- Document Splitter - Overlap Size -->
<VBox spacing="10" GridPane.columnIndex="1" GridPane.rowIndex="2">
<HBox spacing="10" alignment="CENTER_LEFT">
<Label HBox.hgrow="ALWAYS"
maxWidth="Infinity"
text="%Document splitter - overlap size"/>
<Button fx:id="documentSplitterOverlapSizeHelp"
prefWidth="20.0"/>
</HBox>
<IntegerInputField
fx:id="documentSplitterOverlapSizeTextField"
HBox.hgrow="ALWAYS"/>
</VBox>

</GridPane>

<Button onAction="#onResetExpertSettingsButtonClick"
text="%Reset expert settings to default">
<graphic>
<JabRefIconView
glyph="REFRESH"/>
</graphic>
</Button>
</children>
</fx:root>
6 changes: 4 additions & 2 deletions src/main/java/org/jabref/gui/preferences/ai/AiTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

import org.jabref.gui.actions.ActionFactory;
Expand All @@ -21,6 +20,7 @@
import org.jabref.preferences.ai.EmbeddingModel;

import com.airhacks.afterburner.views.ViewLoader;
import com.dlsc.gemsfx.ResizableTextArea;
import com.dlsc.unitfx.DoubleInputField;
import com.dlsc.unitfx.IntegerInputField;
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
Expand All @@ -43,7 +43,7 @@ public class AiTab extends AbstractPreferenceTabView<AiTabViewModel> implements

@FXML private TextField apiBaseUrlTextField;
@FXML private SearchableComboBox<EmbeddingModel> embeddingModelComboBox;
@FXML private TextArea instructionTextArea;
@FXML private ResizableTextArea instructionTextArea;
@FXML private DoubleInputField temperatureTextField;
@FXML private IntegerInputField contextWindowSizeTextField;
@FXML private IntegerInputField documentSplitterChunkSizeTextField;
Expand All @@ -59,6 +59,7 @@ public class AiTab extends AbstractPreferenceTabView<AiTabViewModel> implements
@FXML private Button embeddingModelHelp;
@FXML private Button instructionHelp;
@FXML private Button contextWindowSizeHelp;
@FXML private Button temperatureHelp;
@FXML private Button documentSplitterChunkSizeHelp;
@FXML private Button documentSplitterOverlapSizeHelp;
@FXML private Button ragMaxResultsCountHelp;
Expand Down Expand Up @@ -212,6 +213,7 @@ public void initialize() {
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_API_BASE_URL, dialogService, preferencesService.getFilePreferences()), apiBaseUrlHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_INSTRUCTION, dialogService, preferencesService.getFilePreferences()), instructionHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_CONTEXT_WINDOW_SIZE, dialogService, preferencesService.getFilePreferences()), contextWindowSizeHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_TEMPERATURE, dialogService, preferencesService.getFilePreferences()), temperatureHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_DOCUMENT_SPLITTER_CHUNK_SIZE, dialogService, preferencesService.getFilePreferences()), documentSplitterChunkSizeHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_DOCUMENT_SPLITTER_OVERLAP_SIZE, dialogService, preferencesService.getFilePreferences()), documentSplitterOverlapSizeHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_RAG_MAX_RESULTS_COUNT, dialogService, preferencesService.getFilePreferences()), ragMaxResultsCountHelp);
Expand Down
Loading

0 comments on commit 9ca71c7

Please sign in to comment.