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?

@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.

@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Nov 22, 2025
@Muskan244
Copy link
Contributor Author

I have implemented these changes:

  • Replaced the number text field with a JavaFX Spinner
  • Added tooltip on follow-up questions to view full text
  • Updated wording to include “Automatically”, and chained bindings
  • Replaced Platform.runLater with UiTaskExecutor.runInJavaFXThread
  • Removed unnecessary comments

Let me know if anything else is needed!

Copy link
Member

@InAnYan InAnYan left a comment

Choose a reason for hiding this comment

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

Codewise looks okay

…java to replace ',' with '.' in a comment

Co-authored-by: Ruslan <ruslanpopov1512@gmail.com>
Copy link
Member

@InAnYan InAnYan left a comment

Choose a reason for hiding this comment

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

image

Please change the UI in settings like this:

  1. Remove the word Automatically. Just Generate follow-up questions
  2. And when the checkbox is not ticked, please disable the number input component, and, if possible, gray out the label "Number of follow-up questions"

The button Reset current template for follow-up questions template doesn't work.

Another UI changes:
image

Can you please add colons to Try with examples (Try with examples:) and the same for follow-up questions?

And when there are follow-up questions, can you hide the HBox with example questions?

@InAnYan
Copy link
Member

InAnYan commented Nov 23, 2025

But overall, it looks great! Thank you!

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

InAnYan commented Nov 23, 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

Replying to @koppor .

I think Automatically doesn't make sense. The reason why I introduced previous 2 options is because before one should've manually click "Generate summary" or "Embeddings".

Generation of follow-up questions already implies that they are generated automatically.

Though... maybe I was wrong with the wording "Automatically generate embeddings". Need to dive more

@InAnYan
Copy link
Member

InAnYan commented Nov 23, 2025

I tested more, and found that hover is also available. Cool!

@Muskan244
Copy link
Contributor Author

And when there are follow-up questions, can you hide the HBox with example questions?

I just want to clarify whether this should be done in this PR or in a separate PR, because @koppor commented earlier:

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.

If I am mixing up two different things, please let me know.

@InAnYan
Copy link
Member

InAnYan commented Nov 23, 2025

Ah, sorry, now I understand your confusion.

But, IMHO, the review comments that are left are one-liners, so I think it's not hard to incorporate them in this PR

@Muskan244
Copy link
Contributor Author

Ah, sorry, now I understand your confusion.

But, IMHO, the review comments that are left are one-liners, so I think it's not hard to incorporate them in this PR

Thanks for the clarification. I'll add it in this PR.

@koppor
Copy link
Member

koppor commented Nov 23, 2025

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.
If I am mixing up two different things, please let me know.

I mis-read your question. Please include it here.

- Remove Automatically from the follow-up questions setting
- Disable numeric input and gray label when the checkbox is unchecked
- Fix the reset template button
- Add colons to Try with examples and Follow-up questions
- Hide example questions HBox when follow-up questions are visible
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Nov 23, 2025
@Muskan244
Copy link
Contributor Author

I have implemented these changes:

  • Removed “Automatically” and now it is “Generate follow-up questions”
  • Disabled the number input and grayed out the label when the checkbox is unchecked
  • Fixed the “Reset current template" button for follow-up questions
  • Added colons to “Try with examples:” and “Follow-up questions:”
  • Hid the example questions HBox when follow-up questions are displayed

Let me know if anything else is needed!

Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

During generation, the "try with examples" are still shown. Why? -- I think, it should not.

grafik

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Nov 23, 2025
@Muskan244
Copy link
Contributor Author

During generation, the "try with examples" are still shown. Why? -- I think, it should not.

grafik

Thanks for pointing it out, currently I hide “Try with examples” only when follow-up questions are displayed. When a new message is sent, the follow-up list is cleared in preparation for generating new ones, so the examples reappear during generation.
I’ll update the logic so that “Try with examples” stays hidden while the model is generating follow-up questions as well.

@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Nov 24, 2025
koppor
koppor previously approved these changes Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-up questions in AI chat

5 participants