-
-
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
Changes from all commits
7dad3ec
cd2a456
1e0d59a
8c8d8fd
6402710
c2d03e5
70ea8fa
cacb4cd
dcb12df
e7bbf52
65784bc
f1c8a10
f669126
fc969d6
431bb08
5e9b2a3
53ac53b
f40e89b
e502dcc
c6e109e
442f7e5
f58ccd2
3dfcaeb
18966bd
bc76d55
e705748
e1a37c5
ffc990e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -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; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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; | ||||||||
|
||||||||
|
@@ -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; | ||||||||
|
@@ -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 commentThe 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; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @palukku added inline FXML annotations There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
@FXML private Hyperlink exQuestion2; | ||||||||
@FXML private Hyperlink exQuestion3; | ||||||||
@FXML private HBox exQuestionBox; | ||||||||
|
||||||||
public AiChatComponent(AiService aiService, | ||||||||
StringProperty name, | ||||||||
|
@@ -94,6 +107,8 @@ public void initialize() { | |||||||
initializeChatPrompt(); | ||||||||
initializeNotice(); | ||||||||
initializeNotifications(); | ||||||||
sendExampleQuestions(); | ||||||||
initializeExampleQuestions(); | ||||||||
} | ||||||||
|
||||||||
private void initializeNotifications() { | ||||||||
|
@@ -111,6 +126,35 @@ private void initializeNotice() { | |||||||
noticeText.setText(newNotice); | ||||||||
} | ||||||||
|
||||||||
private void initializeExampleQuestions() { | ||||||||
kaushikaW marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
exQuestion1.setText(EXAMPLE_QUESTION_1); | ||||||||
exQuestion2.setText(EXAMPLE_QUESTION_2); | ||||||||
exQuestion3.setText(EXAMPLE_QUESTION_3); | ||||||||
} | ||||||||
|
||||||||
private void sendExampleQuestions() { | ||||||||
kaushikaW marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
addExampleQuestionAction(exQuestion1); | ||||||||
addExampleQuestionAction(exQuestion2); | ||||||||
addExampleQuestionAction(exQuestion3); | ||||||||
} | ||||||||
|
||||||||
private void addExampleQuestionAction(Hyperlink hyperlink) { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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())) { | ||||||||
InAnYan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
exQuestionBox.getChildren().remove(hyperlink); | ||||||||
if (exQuestionBox.getChildren().size() == 1) { | ||||||||
this.getChildren().remove(exQuestionBox); | ||||||||
} | ||||||||
InAnYan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
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)) | ||||||||
|
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