Skip to content

Added example questions to AI chat #12747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7dad3ec
Added example questions to AI chat
koppor Mar 14, 2025
cd2a456
Merge branch 'main' into fix-for-issue-121
kaushikaW Mar 15, 2025
1e0d59a
Added example questions to AI chat
koppor Mar 14, 2025
8c8d8fd
Merge branch 'main' into fix-for-issue-12745
kaushikaW Mar 16, 2025
6402710
added inline FXML annotaions
kaushikaW Mar 16, 2025
c2d03e5
fix dark mode support for example questions lables
kaushikaW Mar 16, 2025
70ea8fa
refactored codes
kaushikaW Mar 16, 2025
cacb4cd
Added example questions to AI chat
koppor Mar 14, 2025
dcb12df
merged
kaushikaW Mar 16, 2025
e7bbf52
Merge branch 'main' into fix-for-issue-12745
kaushikaW Mar 17, 2025
65784bc
refactor the code for issue #12747
kaushikaW Mar 18, 2025
f1c8a10
refactor the code for issue #12747
kaushikaW Mar 18, 2025
f669126
resolve conflicts with main
kaushikaW Mar 18, 2025
fc969d6
remove unwanted lines in Base.css
kaushikaW Mar 19, 2025
431bb08
remove unwanted lines in AI=iChatComponent.java
kaushikaW Mar 19, 2025
5e9b2a3
Update CHANGELOG.md
kaushikaW Mar 20, 2025
53ac53b
optimized imports in AiChatComponent.fxml
kaushikaW Mar 20, 2025
f40e89b
Merge branch 'fix-for-issue-12745' of https://github.com/kaushikaW/ja…
kaushikaW Mar 20, 2025
e502dcc
Clean up & optimize imports, clean up code style
subhramit Mar 20, 2025
c6e109e
Clean up and optimize imports in `AiTab.fxml`
subhramit Mar 20, 2025
442f7e5
added localization to ai chat
kaushikaW Mar 27, 2025
f58ccd2
Added localization to the AI chat
kaushikaW Mar 27, 2025
3dfcaeb
merged with origin
kaushikaW Mar 27, 2025
18966bd
added localization to ai chat
kaushikaW Mar 27, 2025
bc76d55
added localization to ai chat
kaushikaW Mar 27, 2025
e705748
make example questions strings contant strings
kaushikaW Mar 29, 2025
e1a37c5
Merge remote-tracking branch 'upstream/main' into fix-for-issue-12745
kaushikaW Mar 29, 2025
ffc990e
Merge branch 'main' into fix-for-issue-12745
Siedlerchr Apr 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added a feature for enabling drag-and-drop of files into groups [#12540](https://github.com/JabRef/jabref/issues/12540)
- We added support for reordering keywords via drag and drop, automatic alphabetical ordering, and improved pasting and editing functionalities in the keyword editor. [#10984](https://github.com/JabRef/jabref/issues/10984)
- We added a new functionality where author names having multiple spaces in-between will be considered as separate user block as it does for " and ". [#12701](https://github.com/JabRef/jabref/issues/12701)
- We added a set of example questions to guide users in starting meaningful AI chat interactions. [#12702](https://github.com/JabRef/jabref/issues/12702)
- We added support for loading and displaying BibTeX .blg warnings in the Check integrity dialog, with custom path selection and metadata persistence. [#11998](https://github.com/JabRef/jabref/issues/11998)
- We added an option to choose whether to open the file explorer in the files directory or in the last opened directory when attaching files. [#12554](https://github.com/JabRef/jabref/issues/12554)
- We enhanced support for parsing XMP metadata from PDF files. [#12829](https://github.com/JabRef/jabref/issues/12829)
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -2493,6 +2493,21 @@ journalInfo .grid-cell-b {
-fx-font-size: 1em; -fx-font-weight: bold; -fx-text-fill: -jr-theme;
}

.exampleQuestionStyle {
-fx-background-color: transparent;
-fx-padding: 2px 10px;
-fx-background-radius: 20px;
-fx-border-radius: 20px;
-fx-border-width: 0.062em;
-fx-border-color: -fx-outer-border;
-fx-font-weight: bold;
-fx-underline: false !important;
-fx-text-fill: -fx-text-base-color;
}
.exampleQuestionStyle:hover {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emtpy line missing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed these in #12966

-fx-background-color: rgba(0, 0, 0, 0.12);
}

.refresh {
-fx-background-color: transparent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<?import org.jabref.gui.ai.components.aichat.chatprompt.ChatPromptComponent?>
<?import org.jabref.gui.ai.components.util.Loadable?>
<?import org.jabref.gui.icon.JabRefIconView?>
<?import javafx.scene.control.Hyperlink?>
<fx:root type="javafx.scene.layout.VBox"
spacing="10"
xmlns="http://javafx.com/javafx/17.0.2-ea"
Expand All @@ -20,9 +21,16 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
</padding>
<Loadable fx:id="uiLoadableChatHistory" VBox.vgrow="ALWAYS">
<ChatHistoryComponent fx:id="uiChatHistory" VBox.vgrow="ALWAYS" fitToWidth="true" />
<ChatHistoryComponent fx:id="uiChatHistory" VBox.vgrow="ALWAYS" fitToWidth="true"/>
</Loadable>

<HBox spacing="10" alignment="CENTER" fx:id="exQuestionBox">
<Label text="%Try with examples" BorderPane.alignment="CENTER"/>
<Hyperlink fx:id="exQuestion1" BorderPane.alignment="CENTER" styleClass="exampleQuestionStyle"/>
<Hyperlink fx:id="exQuestion2" BorderPane.alignment="CENTER" styleClass="exampleQuestionStyle"/>
<Hyperlink fx:id="exQuestion3" BorderPane.alignment="CENTER" styleClass="exampleQuestionStyle"/>
</HBox>

<HBox spacing="10">
<Button alignment="CENTER"
fx:id="notificationsButton"
Expand All @@ -32,7 +40,7 @@
<Tooltip text="%Notifications"/>
</tooltip>
</Button>
<ChatPromptComponent fx:id="chatPrompt" HBox.hgrow="ALWAYS" />
<ChatPromptComponent fx:id="chatPrompt" HBox.hgrow="ALWAYS"/>
</HBox>
<HBox alignment="CENTER" spacing="50">
<Label fx:id="noticeText"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import javafx.scene.control.Label;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;

this is needed for my code suggestion to work properly.

import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;

Expand Down Expand Up @@ -46,6 +48,11 @@
public class AiChatComponent extends VBox {
private static final Logger LOGGER = LoggerFactory.getLogger(AiChatComponent.class);

// Example Questions
private static final String EXAMPLE_QUESTION_1 = Localization.lang("What is the goal of the paper?");
private static final String EXAMPLE_QUESTION_2 = Localization.lang("Which methods were used in the research?");
private static final String EXAMPLE_QUESTION_3 = Localization.lang("What are the key findings?");

private final AiService aiService;
private final ObservableList<BibEntry> entries;
private final BibDatabaseContext bibDatabaseContext;
Expand All @@ -57,11 +64,17 @@ public class AiChatComponent extends VBox {

private final ObservableList<Notification> notifications = FXCollections.observableArrayList();


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many empty lines


@FXML private Loadable uiLoadableChatHistory;
@FXML private ChatHistoryComponent uiChatHistory;
@FXML private Button notificationsButton;
@FXML private ChatPromptComponent chatPrompt;
@FXML private Label noticeText;
@FXML private Hyperlink exQuestion1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@palukku added inline FXML annotations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@FXML private Hyperlink exQuestion1;
@FXML private HBox exQuestionBox;
@FXML private Hyperlink exQuestion1;

@FXML private Hyperlink exQuestion2;
@FXML private Hyperlink exQuestion3;
@FXML private HBox exQuestionBox;

public AiChatComponent(AiService aiService,
StringProperty name,
Expand Down Expand Up @@ -94,6 +107,8 @@ public void initialize() {
initializeChatPrompt();
initializeNotice();
initializeNotifications();
sendExampleQuestions();
initializeExampleQuestions();
}

private void initializeNotifications() {
Expand All @@ -111,6 +126,35 @@ private void initializeNotice() {
noticeText.setText(newNotice);
}

private void initializeExampleQuestions() {
exQuestion1.setText(EXAMPLE_QUESTION_1);
exQuestion2.setText(EXAMPLE_QUESTION_2);
exQuestion3.setText(EXAMPLE_QUESTION_3);
}

private void sendExampleQuestions() {
addExampleQuestionAction(exQuestion1);
addExampleQuestionAction(exQuestion2);
addExampleQuestionAction(exQuestion3);
}

private void addExampleQuestionAction(Hyperlink hyperlink) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method addExampleQuestionAction contains nested logic that could be simplified by returning early when the hyperlink text is already in the chat history, following the fail-fast principle.

if (chatPrompt.getHistory().contains(hyperlink.getText())) {
exQuestionBox.getChildren().remove(hyperlink);
if (exQuestionBox.getChildren().size() == 1) {
this.getChildren().remove(exQuestionBox);
}
return;
}
hyperlink.setOnAction(event -> {
onSendMessage(hyperlink.getText());
exQuestionBox.getChildren().remove(hyperlink);
if (exQuestionBox.getChildren().size() == 1) {
this.getChildren().remove(exQuestionBox);
}
});
}

private void initializeChatPrompt() {
notificationsButton.setOnAction(event ->
new PopOver(new NotificationsComponent(notifications))
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/jabref/gui/preferences/ai/AiTab.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<?import org.jabref.gui.icon.JabRefIconView?>
<?import com.dlsc.gemsfx.ResizableTextArea?>
<?import com.dlsc.unitfx.IntegerInputField?>
<?import org.controlsfx.control.SearchableComboBox?>
<?import org.controlsfx.control.textfield.CustomPasswordField?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TextArea?>
<fx:root
spacing="10.0"
type="VBox"
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2714,6 +2714,10 @@ System\ message\ for\ chatting=System message for chatting
User\ message\ for\ chatting=User message for chatting
Completion\ text\ for\ summarization\ of\ a\ chunk=Completion text for summarization of a chunk
Completion\ text\ for\ summarization\ of\ several\ chunks=Completion text for summarization of several chunks
Try\ with\ examples=Try with examples
What\ is\ the\ goal\ of\ the\ paper?=What is the goal of the paper?
Which\ methods\ were\ used\ in\ the\ research?=Which methods were used in the research?
What\ are\ the\ key\ findings?=What are the key findings?

Link=Link
Source\ URL=Source URL
Expand Down
Loading