-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Conversation
src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.java
Outdated
Show resolved
Hide resolved
Please keep in mind the contributing guidelines. |
@palukku Thank you for helping with reviews. |
src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.fxml
Outdated
Show resolved
Hide resolved
# Conflicts: # src/main/java/org/jabref/gui/Base.css # src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.fxml # src/main/java/org/jabref/gui/ai/components/aichat/AiChatComponent.java
</Loadable> | ||
|
||
<HBox spacing="10" alignment="CENTER"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@palukku added external css styles and remove inline css styles
@@ -62,6 +63,9 @@ public class AiChatComponent extends VBox { | |||
@FXML private Button notificationsButton; | |||
@FXML private ChatPromptComponent chatPrompt; | |||
@FXML private Label noticeText; | |||
@FXML private Hyperlink exQuestion1; |
There was a problem hiding this comment.
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
@palukku @subhramit Do I need to add UI changes I done in this issue to the CHANGELOG.md file |
No, just the summary should be fine. Add it to the changelog. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code looks fine now and works as intended.
However, one thing is missing in my opinion: the example questions are always displayed. It would be nice to check the history; if a question has already been sent, remove its "button" from the box. Once all example questions have been asked, remove the entire example box.
You can use chatPrompt#getHistory to check that and remove the hyperlinks by obtaining the parent HBox and removing them from its children.
Well I also though of your opinion , but removing each example question as it's used creates a small issue—once all questions are gone, the user is cant see any example questions . is it ok |
I now remember why we did not hard-code system prompts in the AI preferences: Because of internationalisation. Hard-coded prompts necessitate for JabRef maintainers to translate them to other languages, if the community calls for it, whereas user configurable prompts give users the possibility to use their language of choice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Left some small review comments
</Loadable> | ||
|
||
<HBox spacing="10" alignment="CENTER" fx:id="exQuestionBox"> | ||
<Label text="Try with examples" BorderPane.alignment="CENTER"/> | ||
<Hyperlink fx:id="exQuestion1" text="What is the goal of the paper?" BorderPane.alignment="CENTER" styleClass="exampleQuestionStyle"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for introducing those questions.
Can you make them localized?
I think the proper way is to do this:
- Leave
text
empty in FXML. - Then in some initialization method in Java class, call
setText
withLocalization.lang("...")
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just use the same method as for the "Try with examples" Label by adding a % in front? Or aren't they detected by the localization tests?
</Loadable> | ||
|
||
<HBox spacing="10" alignment="CENTER" fx:id="exQuestionBox"> | ||
<Label text="Try with examples" BorderPane.alignment="CENTER"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be localized with %
.
See more at https://devdocs.jabref.org/code-howtos/localization.html#localization-in-fxml.
@@ -111,6 +119,35 @@ private void initializeNotice() { | |||
noticeText.setText(newNotice); | |||
} | |||
|
|||
private void initializeExampleQuestions() { | |||
exQuestion1.setText(Localization.lang("What is the goal of the paper?")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The strings for example questions should be defined as constants to avoid magic strings and improve maintainability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, private static final String ...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koppor This is a false positive. For l10n this doesn't work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about
private static final String EXAMPLE_QUESTION_1 = Localization.lang("What is the goal of the paper?"));
on top of the class - to make it very easy to update the example question.
I also can follow the line of argumetnation that find-in-all-files also finds the string and then can be replaced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the String you want to localize directly, do not use members or local variables: Localization.lang("Translate me"); instead of Localization.lang(someVariable) (possibly in the form someVariable = Localization.lang("Translate me")
https://devdocs.jabref.org/code-howtos/localization.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I confused it with that one
@kaushikaW Please merge |
addExampleQuestionAction(exQuestion3); | ||
} | ||
|
||
private void addExampleQuestionAction(Hyperlink hyperlink) { |
There was a problem hiding this comment.
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.
@trag-bot didn't find any issues in the code! ✅✨ |
@InAnYan why this PR filing do I have mentioned wrong issue no in the PR description. |
-fx-underline: false !important; | ||
-fx-text-fill: -fx-text-base-color; | ||
} | ||
.exampleQuestionStyle:hover { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emtpy line missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed these in #12966
@@ -57,11 +64,17 @@ public class AiChatComponent extends VBox { | |||
|
|||
private final ObservableList<Notification> notifications = FXCollections.observableArrayList(); | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many empty lines
Fixes #12702
Added 3 example questions to the AI chat tab section (see the screenshot).
Currently, the 3 questions are hardcoded in the codebase and are not being generated by the AI model.
Some extra styles have been added to improve the user experience.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)