-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Added example questions to AI chat #12747
base: main
Are you sure you want to change the base?
Changes from 13 commits
7dad3ec
cd2a456
1e0d59a
8c8d8fd
6402710
c2d03e5
70ea8fa
cacb4cd
dcb12df
e7bbf52
65784bc
f1c8a10
f669126
fc969d6
431bb08
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; | ||||||||
|
||||||||
|
@@ -62,6 +64,10 @@ 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 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 +100,7 @@ public void initialize() { | |||||||
initializeChatPrompt(); | ||||||||
initializeNotice(); | ||||||||
initializeNotifications(); | ||||||||
sendExampleQuestions(); | ||||||||
} | ||||||||
|
||||||||
private void initializeNotifications() { | ||||||||
|
@@ -111,6 +118,29 @@ private void initializeNotice() { | |||||||
noticeText.setText(newNotice); | ||||||||
} | ||||||||
|
||||||||
private void sendExampleQuestions() { | ||||||||
kaushikaW marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
addExampleQuestionAction(exQuestion1); | ||||||||
addExampleQuestionAction(exQuestion2); | ||||||||
addExampleQuestionAction(exQuestion3); | ||||||||
} | ||||||||
|
||||||||
private void addExampleQuestionAction(Hyperlink hyperlink) { | ||||||||
if (chatPrompt.getHistory().contains(hyperlink.getText())) { | ||||||||
exQuestionBox.getChildren().remove(hyperlink); | ||||||||
if (exQuestionBox.getChildren().size() == 1) { | ||||||||
this.getChildren().remove(exQuestionBox); | ||||||||
} | ||||||||
Comment on lines
+130
to
+132
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. Code duplication exists in two places where the same condition and removal logic is repeated. Should be extracted to a separate method. |
||||||||
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)) | ||||||||
|
@@ -174,8 +204,8 @@ private List<Notification> updateNotificationsForEntry(BibEntry entry) { | |||||||
entry.getFiles().stream().map(file -> aiService.getIngestionService().ingest(file, bibDatabaseContext)).forEach(ingestionStatus -> { | ||||||||
switch (ingestionStatus.getState()) { | ||||||||
case PROCESSING -> notifications.add(new Notification( | ||||||||
Localization.lang("File %0 is currently being processed", ingestionStatus.getObject().getLink()), | ||||||||
Localization.lang("After the file will be ingested, you will be able to chat with it.") | ||||||||
Localization.lang("File %0 is currently being processed", ingestionStatus.getObject().getLink()), | ||||||||
Localization.lang("After the file will be ingested, you will be able to chat with it.") | ||||||||
)); | ||||||||
|
||||||||
case ERROR -> { | ||||||||
|
@@ -270,3 +300,4 @@ private void deleteLastMessage() { | |||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
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. Revert this as well |
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.
Remove these extra newlines