Skip to content

Conversation

@Muskan244
Copy link
Contributor

Closes #12243

This PR implements a follow-up questions feature to AI chat. After the AI responds to a user's question, the system automatically generates 3-5 relevant follow-up questions that appear as clickable links below the chat.
Changes:

  • Added new "Generate follow-up questions" setting in AI preferences
  • Created FollowUpQuestionGenerator class to generate questions via AI
  • Integrated follow-up generation into AiChatLogic after each AI response
  • Added UI component to display clickable follow-up question links
  • Questions are cleared when any new message is sent

Steps to test

  1. Go to Preferences → AI, enable AI with API key, and check "Generate follow-up questions"
  2. Open an entry with a PDF attached and click the "AI chat" tab
  3. Send a question and verify that 3-5 clickable follow-up questions appear below the chatScreenshot 2025-11-17 at 2 21 31 PM
  4. Click a follow-up question and verify it sends automatically and new questions appear
  5. Disable the setting in preferences and verify no follow-up questions appear

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • I added screenshots in the PR description (if change is visible to the user)
  • I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • [/] I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

Implement automatic generation of follow-up questions after AI responses in the chat interface. Users can click suggested questions to continue the conversation naturally.
Changes:
- Add Generate follow-up questions setting in AI preferences
- Create FollowUpQuestionGenerator to generate questions via AI
- Update AiChatLogic to generate questions after each response
- Display clickable follow-up question links in chat UI
- Clear questions when new message is sent
Implement automatic generation of follow-up questions after AI responses in the chat interface. Users can click suggested questions to continue the conversation naturally.
Changes:
- Add Generate follow-up questions setting in AI preferences
- Create FollowUpQuestionGenerator to generate questions via AI
- Update AiChatLogic to generate questions after each response
- Display clickable follow-up question links in chat UI
- Clear questions when new message is sent

# Conflicts:
#	jablib/src/main/resources/csl-styles
@koppor koppor requested review from InAnYan and ThiloteE November 20, 2025 10:40
@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 20, 2025
@ThiloteE

This comment was marked as resolved.

@Muskan244

This comment was marked as resolved.

@ThiloteE

This comment was marked as resolved.

@Muskan244

This comment was marked as resolved.

@ThiloteE
Copy link
Member

  1. Things I would like you to address in this PR:
    I tried generating follow up questions and it simply works. Great job!
    Only one tiny thing is amiss: I think you should limit the number of follw up questions to three (or maybe add a preference that lets users choose the number and set the default to three). As you can see the questions may be too long for the GUI:
    grafik

  2. Possible follow up PR:
    Since we have a user base that does not only speak English, it would be good to expose this instruction as a template in the AI preferences, so that every user can manually translate this instruction to their own language, Here:
    grafik
    Maybe far in the future, we can make it dependent on the set user language, but that's a long shot.

@InAnYan
Copy link
Member

InAnYan commented Nov 21, 2025

What would anyone think about this:

I think there are too many buttons for questions. What if we could hide "Try these examples" as soon as there are follow up questions?

CHANGELOG.md Outdated
- We added the possibility to configure the email provided to unpaywall. [#14340](https://github.com/JabRef/jabref/pull/14340)
- We added a "Regenerate" button for the AI chat allowing the user to make the language model reformulate its response to the previous prompt. [#12191](https://github.com/JabRef/jabref/issues/12191)
- We added support for transliteration of fields to English and automatic transliteration of generated citation key. [#11377](https://github.com/JabRef/jabref/issues/11377)
- We added a "Generate follow-up questions" feature to AI chat that suggests relevant questions after each AI response. [#12243](https://github.com/JabRef/jabref/issues/12243)
Copy link
Member

Choose a reason for hiding this comment

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

I think you can remove "Generate . So maybe "we added the generation of follow-up questions in AI chat"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will update the CHANGELOG.md

public static final boolean ENABLE_CHAT = false;
public static final boolean AUTO_GENERATE_EMBEDDINGS = false;
public static final boolean AUTO_GENERATE_SUMMARIES = false;
public static final boolean GENERATE_FOLLOW_UP_QUESTIONS = false;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it can be true by default? Because I think users could miss this feature if it's turned off.

However, on the other hand, users interested in AI features will always open AI preferences at least once in order to add API key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I set it as true by default or leave it as false?

Copy link
Member

Choose a reason for hiding this comment

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

I want to know other people's opinions, but for now you can leave false

Copy link
Member

Choose a reason for hiding this comment

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

Options:

  • nagging after some weeks: "Did you know?" -- I don't like this
  • have it turned on - and enable quick turn off (we have this at user comment field)
  • have it turned off - and have a quick-turn on possibility (as we do at Mr. DLib)

I would vote for option 3 - but as follow-up PR to have the PRs reviewable and get finished parts in main fast.

@github-actions github-actions bot added status: changes-required Pull requests that are not yet complete and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Nov 21, 2025
@InAnYan
Copy link
Member

InAnYan commented Nov 21, 2025

Okay, good! But the follow up questions template must be an AiTemplate

@Muskan244
Copy link
Contributor Author

  1. Things I would like you to address in this PR:
    I tried generating follow up questions and it simply works. Great job!
    Only one tiny thing is amiss: I think you should limit the number of follw up questions to three (or maybe add a preference that lets users choose the number and set the default to three). As you can see the questions may be too long for the GUI:

I will limit the number of generated follow-up questions to three by default and will try to add the preference for users too.

2. Possible follow up PR:
Since we have a user base that does not only speak English, it would be good to expose this instruction as a template in the AI preferences, so that every user can manually translate this instruction to their own language, Here:

I would be happy to look into adding this in a follow-up PR.

@Muskan244
Copy link
Contributor Author

Okay, good! But the follow up questions template must be an AiTemplate

Thanks, I will update the follow-up questions to use an AiTemplate instead of the current inline string.

…mplate

- Default follow-up questions at 3
- New user preference to configure maximum number
- Converted prompt to AiTemplate for consistency
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Nov 21, 2025
@Muskan244
Copy link
Contributor Author

I have implemented these changes:

  • Limited the number of generated follow-up questions to three by default
  • Added a user preference to customize this limit
  • Converted the follow-up questions instruction into an AiTemplate

What would anyone think about this:

I think there are too many buttons for questions. What if we could hide "Try these examples" as soon as there are follow up questions?

I have not worked on this part yet. If you would like me to include it in this PR, please let me know and I will be happy to update it.

@koppor
Copy link
Member

koppor commented Nov 21, 2025

I think there are too many buttons for questions. What if we could hide "Try these examples" as soon as there are follow up questions?

I have not worked on this part yet. If you would like me to include it in this PR, please let me know and I will be happy to update it.

Very OK for me to do that in a separate PR.

@koppor
Copy link
Member

koppor commented Nov 21, 2025

  • Isn't there a JavaFX element for increasing and decreasing numbers?
  • Should we add "Automatically" at the new bullet point? - To be consistent to the other two settings?
grafik

// Get the current questions (this is thread-safe)
List<String> questions = new ArrayList<>(aiChatLogic.getFollowUpQuestions());

// Update UI on the JavaFX Application Thread
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Update UI on the JavaFX Application Thread

}

private void updateFollowUpQuestions() {
// Get the current questions (this is thread-safe)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Get the current questions (this is thread-safe)

autoGenerateEmbeddings.selectedProperty().bindBidirectional(viewModel.autoGenerateEmbeddings());
autoGenerateEmbeddings.disableProperty().bind(viewModel.disableAutoGenerateEmbeddings());
generateFollowUpQuestions.selectedProperty().bindBidirectional(viewModel.generateFollowUpQuestions());
followUpQuestionsCountTextField.valueProperty().addListener((observable, oldValue, newValue) ->
Copy link
Member

Choose a reason for hiding this comment

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

for unused varialbes, use _.

Didn't that IntelliJ show to you - or do you use another IDE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, IntelliJ did highlight it. I will replace the unused variables with _ to follow the convention.

Comment on lines +82 to +85
line = line.trim();
line = line.replaceAll("^[-*•]\\s*", "");
line = line.replaceAll("^\\d+\\.\\s*", "");
line = line.replaceAll("^[\"']|[\"']$", "");
Copy link
Member

Choose a reason for hiding this comment

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

Chain these calls instead of assignments to the same variable

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Nov 21, 2025
@koppor
Copy link
Member

koppor commented Nov 21, 2025

  • Please add a hover on the questions - I cannot see the full question
    grafik

@Muskan244
Copy link
Contributor Author

  • Isn't there a JavaFX element for increasing and decreasing numbers?

Yes, I think there is JavaFX Spinner<Integer>. I will replace text field so users can easily increase/decrease the number of follow-up questions.

  • Should we add "Automatically" at the new bullet point? - To be consistent to the other two settings?

I will also update it to include “Automatically” for consistency with the other bullet points.

List<String> questions = new ArrayList<>(aiChatLogic.getFollowUpQuestions());

// Update UI on the JavaFX Application Thread
Platform.runLater(() -> {
Copy link
Member

Choose a reason for hiding this comment

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

Use UiTaskExecutor.runInJavaFXThread( () ->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: changes-required Pull requests that are not yet complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-up questions in AI chat

5 participants