-
-
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
Customizable AI templates #11884
Conversation
# Conflicts: # src/main/java/module-info.java # src/main/java/org/jabref/gui/preferences/ai/AiTab.java # src/main/java/org/jabref/logic/ai/AiService.java # src/main/resources/l10n/JabRef_en.properties
Side comment: This refs koppor#392, where we first wanted Apache Velocity - but then wanted Thymeleaf (and did not want Apache FreeMarker). |
I think it I necessary now to finally create an ADR now for the template engine. Please create a simple one, with your decision drivers for velocity and we can fill in the others for the next dev-call to decide on it together. I think we need to decide on it, since we should not have multiple templating engines running in favor of resources. |
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.
DOCUMENT: | ||
$document | ||
|
||
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.
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:
- In form of chat: a list of messages. For this situation we need both system + user message templates.
- In form of text that should be completed. This is only one template + I've seen that this approach is typically chosen for summarization. And I think it's easier.
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
SUMMARIES: | ||
$summaries | ||
|
||
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.
I don't understand that - the FINAL OVERVIEW should be generated? Why is it part of the prompt?
src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java
Outdated
Show resolved
Hide resolved
return switch (this) { | ||
case CHATTING_SYSTEM_MESSAGE -> | ||
Localization.lang("System message for chatting"); | ||
case CHATTING_USER_MESSAGE -> | ||
Localization.lang("User message for chatting"); | ||
case SUMMARIZATION_CHUNK -> | ||
Localization.lang("Summarization chunk"); | ||
case SUMMARIZATION_COMBINE -> | ||
Localization.lang("Summarization combine"); | ||
}; |
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.
We can actually define fields in enums, so here we can define a field called localizedName and define the relevant constructor. After that we can write something like this: CHATTING_SYSTEM_MESSAGE(Localization.lang("System message for chatting"))
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.
But I'm not sure, if the names are properties of templates, and especially localized ones
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.
If that is the case we can do something else, but if all strings are static having it as a field is better IMO.
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.
Just call Localization.lang
in the enum. Why not? -- The initialization of the enum should take care about the localiaztion. When using toString
, the stored localized string is returned.
I know this will cause troubles when users change the UI language. Since language switch is not done that often, I accept this.
I think, a related discussion was going on at #8304 and ADR-0023.
# Conflicts: # src/main/java/org/jabref/logic/ai/summarization/GenerateSummaryTask.java # src/main/java/org/jabref/logic/ai/summarization/SummariesService.java # src/main/resources/l10n/JabRef_en.properties
Coming from #11900, |
@InAnYan Can you resolve the conflicts? I think, then, this can go in - and JabRef/user-documentation#519 can also be merged? |
Cool, the ADR is merged! I'll fix everything, but in the evening |
# Conflicts: # src/main/java/org/jabref/gui/preferences/ai/AiTabViewModel.java # src/main/java/org/jabref/logic/ai/AiDefaultPreferences.java
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.
Comments on naming.
Moreover, can you change from dropdown to tabs?
JabRef uses tabs as UX pattern for options. (Moreover, it is one click for change to another template - for instanc,e when trying to make them consistent, comparing them, ... this is useful)
Now, all LLM templates can be customized by users. Previously, only the system message was customizable in a limited way.
I used Apache Velocity template engine.
Mandatory checks
- [ ] Change inCHANGELOG.md
described in a way that is understandable for the average user (if applicable)- [ ] Tests created for changes (if applicable)