-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Customizable AI templates #11884
Merged
Merged
Customizable AI templates #11884
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c2b8a29
Start to work
InAnYan 1ef2958
Fix runtime problems and checkers
InAnYan 9073051
Merge branch 'upstream-main' into ai-templates
InAnYan d9c32b5
Merge with main
InAnYan d831242
Fix from code review
InAnYan 7119253
Merge branch 'upstream-main' into ai-templates
InAnYan eadec6a
Update from merge
InAnYan 4f29a00
Merge branch 'upstream-main' into ai-templates
InAnYan f96037d
Fix compiler errors
InAnYan 1f00416
Fix from code review
InAnYan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.jabref.logic.ai.templates.AiTemplate; | ||
import org.jabref.model.ai.AiProvider; | ||
import org.jabref.model.ai.EmbeddingModel; | ||
|
||
|
@@ -80,6 +81,46 @@ public String toString() { | |
|
||
public static final int FALLBACK_CONTEXT_WINDOW_SIZE = 8196; | ||
|
||
public static final Map<AiTemplate, String> TEMPLATES = Map.of( | ||
AiTemplate.CHATTING_SYSTEM_MESSAGE, """ | ||
You are an AI assistant that analyses research papers. You answer questions about papers. | ||
You will be supplied with the necessary information. The supplied information will contain mentions of papers in form '@citationKey'. | ||
Whenever you refer to a paper, use its citation key in the same form with @ symbol. Whenever you find relevant information, always use the citation key. | ||
|
||
Here are the papers you are analyzing: | ||
#foreach( $entry in $entries ) | ||
${CanonicalBibEntry.getCanonicalRepresentation($entry)} | ||
#end""", | ||
|
||
AiTemplate.CHATTING_USER_MESSAGE, """ | ||
$message | ||
|
||
Here is some relevant information for you: | ||
#foreach( $excerpt in $excerpts ) | ||
${excerpt.citationKey()}: | ||
${excerpt.text()} | ||
#end""", | ||
|
||
AiTemplate.SUMMARIZATION_CHUNK, """ | ||
Please provide an overview of the following text. It is a part of a scientific paper. | ||
The summary should include the main objectives, methodologies used, key findings, and conclusions. | ||
Mention any significant experiments, data, or discussions presented in the paper. | ||
|
||
DOCUMENT: | ||
$document | ||
|
||
OVERVIEW:""", | ||
|
||
AiTemplate.SUMMARIZATION_COMBINE, """ | ||
You have written an overview of a scientific paper. You have been collecting notes from various parts | ||
of the paper. Now your task is to combine all of the notes in one structured message. | ||
|
||
SUMMARIES: | ||
$summaries | ||
|
||
FINAL OVERVIEW:""" | ||
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. I don't understand that - the FINAL OVERVIEW should be generated? Why is it part of the prompt? |
||
); | ||
|
||
public static List<String> getAvailableModels(AiProvider aiProvider) { | ||
return Arrays.stream(AiDefaultPreferences.PredefinedChatModel.values()) | ||
.filter(model -> model.getAiProvider() == aiProvider) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't understand that - this should be generated?
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.
About that. There are two ways of asking AI to generate text:
For the summarization I chose 2nd approach. That is why you are seeing "OVERVIEW" and "FINAL OVERVIEW"
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.
Because without those words AI won't understand what should it do