Skip to content
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

AI chatting functionality #11430

Merged
merged 423 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
423 commits
Select commit Hold shift + click to select a range
8ca536e
Fix the code from code review
InAnYan Jul 6, 2024
1e7221a
Fix from code review and create new AiChatTabWorking
InAnYan Jul 6, 2024
874e513
Improve chat history storage code
koppor Jul 4, 2024
a3b9dd9
More fix from code review
InAnYan Jul 6, 2024
2d65495
Remove obsolete parameter
koppor Jul 8, 2024
08c77ce
Add JavaDoc comment
koppor Jul 8, 2024
ab9ff18
Fix checkstyle
koppor Jul 8, 2024
eb00e30
Fix JavaDoc
koppor Jul 8, 2024
3e6ffb1
Fix more checkstyle
koppor Jul 8, 2024
154d621
More checkstyle fixes
koppor Jul 8, 2024
7e70584
Fix code changes
InAnYan Jul 8, 2024
27cb183
Merge remote-tracking branch 'origin/ai-pr-1' into ai-pr-1
InAnYan Jul 8, 2024
3fb4cbb
Improve the PR
InAnYan Jul 10, 2024
0d617b5
Merge remote-tracking branch 'origin/main' into ai-pr-1
koppor Jul 10, 2024
b3598f6
Rework ADR-0031 to enable to use another option
koppor Jul 10, 2024
ef8b16c
Add many LOGGEr.trace statements
koppor Jul 10, 2024
1b377ee
Change "message window" to "context window"
InAnYan Jul 10, 2024
6ba5cc3
Fix compiler errors
InAnYan Jul 10, 2024
861da12
Fix issue list index issue of langchain4j
koppor Jul 10, 2024
53f1b0f
Fix lint issue
koppor Jul 10, 2024
0034f94
Update 0031-store-chats-alongside-database.md
koppor Jul 10, 2024
81f0278
More tracing
koppor Jul 10, 2024
8f6b252
Merge remote-tracking branch 'origin/main' into ai-pr-1
koppor Jul 11, 2024
e50ff5c
Refine logging
koppor Jul 12, 2024
ee4526c
Remove closing of AiChatLanguageModel (because it's not closable)
InAnYan Jul 12, 2024
ed748a4
Use external package for OpenAI API connection
InAnYan Jul 13, 2024
94df8df
Provide a custom executor for RetrievalAugmentor
InAnYan Jul 13, 2024
e44e5cc
Merge branch 'refs/heads/ai-pr-1-default-retrieval' into ai-pr-1-jvm-…
InAnYan Jul 13, 2024
92c071f
Fix shutdown issue (I hope)
InAnYan Jul 13, 2024
ca984a3
Refactor classes
InAnYan Jul 13, 2024
9eae4ee
Change BibDatabaseChatHistoryFile
InAnYan Jul 13, 2024
7edec3f
Revert BibDatabaseChatHistoryFile to old version because of langchain4j
InAnYan Jul 13, 2024
a931e44
Make round corners for chat messages
InAnYan Jul 13, 2024
43db814
Refactor embeddings generation
InAnYan Jul 13, 2024
76a6ffa
Refactor embeddings generation
InAnYan Jul 14, 2024
58cbe6d
Refactor embeddings generation
InAnYan Jul 14, 2024
d4be288
Merge branch 'main' into ai-pr-1
koppor Jul 15, 2024
d55ba9f
Merge remote-tracking branch 'origin/ai-pr-1' into HEAD
koppor Jul 15, 2024
a86a728
Fix CHANGELOG.md
koppor Jul 16, 2024
6802017
Remove jpro-mdfx
koppor Jul 17, 2024
74e159f
Add comment
koppor Jul 17, 2024
7f55bcd
Fix localizations
InAnYan Jul 17, 2024
d8d05d4
Merge branch 'refs/heads/upstream-main' into ai-pr-1
InAnYan Jul 17, 2024
b1482f2
Fix checkstyle and remove OpenAI from PRIVACY.md
InAnYan Jul 17, 2024
4f432b7
Remove unnecessary comments
InAnYan Jul 17, 2024
dd70b89
Fix privacy notice UI
InAnYan Jul 17, 2024
9ed8119
Introduce new ApiKeyMissingComponent
InAnYan Jul 17, 2024
bced287
Thanks Tobiaz Diez for writing such a good EntryEditorTab class
InAnYan Jul 17, 2024
55bf2af
Fix InAnYan/jabref issues
InAnYan Jul 17, 2024
bdbb808
Merge remote-tracking branch 'ruslan/ai-pr-1' into ai-pr-1
koppor Jul 17, 2024
aebb0d1
Merge `build.gradle` and `settings.gradle` from main branch
koppor Jul 17, 2024
4c823a7
Merge remote-tracking branch 'refs/remotes/upstream/main' into ai-pr-1
InAnYan Jul 19, 2024
aaebb67
Update ADRs
InAnYan Jul 19, 2024
e1d07ea
Implement rethought ADR for chat history
InAnYan Jul 19, 2024
79c3383
Use OpenAI embedding model
InAnYan Jul 19, 2024
2d95ac5
Use Deep Java embedding model
InAnYan Jul 20, 2024
6a72d65
Remove old langchain4j embedding models
InAnYan Jul 20, 2024
6cd8d2c
Fix checkstyle errors
InAnYan Jul 20, 2024
afeb158
Merge branch 'refs/heads/use-deepjava' into ai-pr-1
InAnYan Jul 20, 2024
46bc6be
Fix checkstyle and remove old dependencies
InAnYan Jul 20, 2024
6e2d60c
Fixes from code review
InAnYan Jul 22, 2024
9e50ea2
Merge branch 'refs/heads/upstream-main' into ai-pr-1
InAnYan Jul 22, 2024
9453f3a
Restructure
InAnYan Jul 23, 2024
b2dd89d
Fix checkstyle errors
InAnYan Jul 23, 2024
ce35270
Add API base URL parameter
InAnYan Jul 24, 2024
b3fa7f0
Fix localization
InAnYan Jul 24, 2024
f669a95
Merge branch 'refs/heads/upstream-main' into ai-pr-1
InAnYan Jul 29, 2024
efed0cc
Fix from code review + ADR
InAnYan Jul 29, 2024
cef4a76
Merge branch 'refs/heads/ai-pr-1' into ai-week2
InAnYan Jul 29, 2024
d145b5b
Something broken
InAnYan Jul 29, 2024
b53a02f
Now MistralAI and Hugging Face work
InAnYan Jul 29, 2024
5c3cb69
Fix base URL for other LLM providers
InAnYan Jul 29, 2024
cf321ae
Fix base URL for other LLM providers
InAnYan Jul 29, 2024
7a88206
Refactor MVStore usage
InAnYan Jul 30, 2024
eb36298
Load embedding model in background
InAnYan Jul 30, 2024
04ab84f
Bump langchain4j version
InAnYan Jul 30, 2024
0f588c2
Merge branch 'refs/heads/ai-pr-1' into ai-week2
InAnYan Jul 30, 2024
39a0170
Fix bug
InAnYan Jul 30, 2024
70f74ad
Merge branch 'refs/heads/upstream-main' into ai-pr-1
InAnYan Jul 30, 2024
01bd201
Merge branch 'refs/heads/ai-pr-1' into ai-week2
InAnYan Jul 30, 2024
362c7cd
Fix checkstyle and localization
InAnYan Jul 30, 2024
9e3d9f1
Implement summarization
InAnYan Jul 30, 2024
72e093c
Fix checkstyle and localization
InAnYan Jul 30, 2024
1bd8987
Improve PrivacyNoticeComponent
InAnYan Jul 31, 2024
11d33fa
Fix from code review
InAnYan Jul 31, 2024
c5acfc0
Merge branch 'refs/heads/add-summarization' into ai-pr-1
InAnYan Jul 31, 2024
8d73e7f
Update localization
InAnYan Jul 31, 2024
23ecad6
Wrap text
InAnYan Jul 31, 2024
6a4096b
Add padding
InAnYan Jul 31, 2024
385e58c
Fix markdown
InAnYan Jul 31, 2024
debfe15
Use stuff algorithm
InAnYan Jul 31, 2024
52d2488
Add GPT-4o-mini
InAnYan Jul 31, 2024
edf752b
Make chat model editable
InAnYan Jul 31, 2024
f017208
Update context window size and summarization
InAnYan Aug 1, 2024
608f22b
Merge branch 'refs/heads/upstream-main' into ai-pr-1
InAnYan Aug 1, 2024
05b404f
Fix checkstyle
InAnYan Aug 1, 2024
eb8b1fc
Update PrivacyNoticeComponent.fxml
InAnYan Aug 1, 2024
7560124
Update AI summary tab
InAnYan Aug 1, 2024
ede993c
Fix localization
InAnYan Aug 1, 2024
0f76e46
Merge remote-tracking branch 'origin/main' into ai-pr-1
koppor Aug 2, 2024
1a62197
Change order so that there is no diff
koppor Aug 2, 2024
91eb6e4
Reorrder dependencies
koppor Aug 2, 2024
c38905c
Add missing CHANGELOG.md entry
koppor Aug 2, 2024
653e82c
Refine ADR-0033
koppor Aug 2, 2024
b5a38c7
Refine ADR0034
koppor Aug 2, 2024
5b3ec78
Fix typos
koppor Aug 2, 2024
b07cf61
Refine ADR-0036
koppor Aug 2, 2024
d2af1fc
Fix ADR-0037
koppor Aug 2, 2024
6449697
Fix title case
koppor Aug 2, 2024
36d10ff
Fix changes in module-info.java
koppor Aug 2, 2024
a8c42b4
Readd removed requires org.apache.httpcomponents.core5.httpcore5
koppor Aug 2, 2024
4361c88
Revert change in JabRefGUI to avoid conflicts
koppor Aug 2, 2024
1d7f7a9
Remove empty lines
koppor Aug 2, 2024
9e50899
Reorder entries in JabRef_en.properties
koppor Aug 2, 2024
219657a
Simplify SummariesStorage (and add test)
koppor Aug 2, 2024
1cd8057
Use region/endregion
koppor Aug 2, 2024
38be8bd
Fix position of comment
koppor Aug 2, 2024
143fde0
Add comment why the event bus is needed
koppor Aug 2, 2024
3b8bc26
Do not show exception to the user - just that an error is occurred (s…
koppor Aug 2, 2024
5018f58
Use "URL %0" without colon (consistency)
koppor Aug 2, 2024
fae1bb2
Fix typos
koppor Aug 2, 2024
4155b57
History has to be kept
koppor Aug 2, 2024
8aaf0da
Remove empty lines
koppor Aug 2, 2024
9a70e61
Fix language (hopefully)
koppor Aug 2, 2024
c4c8229
Compilefix
koppor Aug 2, 2024
0a33b34
Simplify BibDatabaseChatHistoryManager
koppor Aug 2, 2024
4307697
Fix from code review
InAnYan Aug 3, 2024
cb5afca
Merge branch 'refs/heads/upstream-main' into ai-pr-1
InAnYan Aug 3, 2024
89d7f77
Fix issue #103
InAnYan Aug 3, 2024
44e8bdf
Rework embeddings cache clearing
InAnYan Aug 3, 2024
c245e73
Fix #99 and partially #101
InAnYan Aug 3, 2024
adfff75
Partially fixing shutdown issues and UI progress monitor issue
InAnYan Aug 3, 2024
e1a895b
Merge branch 'main' into ai-pr-1
koppor Aug 4, 2024
4c3623d
Add "requires scala.library" and add "region:" / "endregion"
koppor Aug 4, 2024
df7fcee
More grouping (move de.saxsys.mvvmfx.validation up)
koppor Aug 4, 2024
d38121e
Add alphabetical hint
koppor Aug 4, 2024
a581cdd
Merge remote-tracking branch 'origin/add-scala.library-as-requirement…
koppor Aug 4, 2024
e84b992
Fix https://github.com/InAnYan/jabref/issues/101 and https://github.c…
InAnYan Aug 4, 2024
3a90caf
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 4, 2024
02c23b8
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 4, 2024
152b3a0
Discard changes to settings.gradle
koppor Aug 4, 2024
f545390
Fix https://github.com/InAnYan/jabref/issues/105
InAnYan Aug 4, 2024
9d1869d
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 4, 2024
57617b2
Follow-up fix for https://github.com/InAnYan/jabref/issues/103
InAnYan Aug 4, 2024
4a72830
Follow-up fix for https://github.com/InAnYan/jabref/issues/103
InAnYan Aug 4, 2024
f55d6f4
Remove obsolete class
koppor Aug 4, 2024
ea68114
Merge branch 'ai-pr-1' of github.com:JabRef/jabref into ai-pr-1
koppor Aug 4, 2024
390f6da
Partially fix https://github.com/InAnYan/jabref/issues/98
InAnYan Aug 4, 2024
637d14e
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 4, 2024
e71994e
We do need dependencies to the AI providers, don't we?
koppor Aug 4, 2024
ed36c53
Merge branch 'ai-pr-1' of github.com:JabRef/jabref into ai-pr-1
koppor Aug 4, 2024
f0be2ed
Fix https://github.com/InAnYan/jabref/issues/93
InAnYan Aug 4, 2024
12cfde8
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 4, 2024
99e713d
Simplify code
koppor Aug 4, 2024
6e7c01a
Merge branch 'ai-pr-1' of github.com:JabRef/jabref into ai-pr-1
koppor Aug 4, 2024
e8b0e9c
Partially fix https://github.com/InAnYan/jabref/issues/92
InAnYan Aug 4, 2024
39b5b5e
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 4, 2024
529b1f9
Fix checkstyle and localization
InAnYan Aug 4, 2024
38169a8
Fix hyperlinks and text in ApiKeyMissingComponent
InAnYan Aug 4, 2024
881f6a9
Fixes from code review
InAnYan Aug 4, 2024
04c5840
Merge branch 'main' into ai-pr-1
koppor Aug 4, 2024
7a618da
Merge remote-tracking branch 'origin/main' into ai-pr-1
koppor Aug 4, 2024
adb6194
Fix https://github.com/InAnYan/jabref/issues/120
InAnYan Aug 5, 2024
ec3fef9
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 5, 2024
549ac5a
Remove "X% work done" messages
InAnYan Aug 5, 2024
9adf0bc
Fix https://github.com/InAnYan/jabref/issues/114
InAnYan Aug 5, 2024
b5a1843
Partially fix https://github.com/InAnYan/jabref/issues/113
InAnYan Aug 5, 2024
f4f23e9
Partially fix https://github.com/InAnYan/jabref/issues/110
InAnYan Aug 5, 2024
a82eb21
Fix https://github.com/InAnYan/jabref/issues/110
InAnYan Aug 5, 2024
b80c35a
Fix https://github.com/InAnYan/jabref/issues/111
InAnYan Aug 5, 2024
7c1a27e
Improve embedding model downloading notifications
InAnYan Aug 5, 2024
f9d6dbf
Fix https://github.com/InAnYan/jabref/issues/124
InAnYan Aug 6, 2024
123af11
Fix https://github.com/InAnYan/jabref/issues/122
InAnYan Aug 6, 2024
8cca5fb
Fix wrong context window size when expert settings customization is t…
InAnYan Aug 6, 2024
f79f874
Attempt to fix https://github.com/InAnYan/jabref/issues/95
InAnYan Aug 6, 2024
98a3640
Finally fix https://github.com/InAnYan/jabref/issues/105
InAnYan Aug 6, 2024
182ab00
Fix https://github.com/InAnYan/jabref/issues/108
InAnYan Aug 6, 2024
2468fec
Attempt to fix https://github.com/InAnYan/jabref/issues/98
InAnYan Aug 6, 2024
1d4c383
Fix for https://github.com/InAnYan/jabref/issues/104
InAnYan Aug 6, 2024
547da5d
Fix for https://github.com/InAnYan/jabref/issues/98
InAnYan Aug 6, 2024
3b2887b
Fix for https://github.com/InAnYan/jabref/issues/95#issuecomment-2269…
InAnYan Aug 6, 2024
49ce737
Fix for https://github.com/InAnYan/jabref/issues/98#issuecomment-2271…
InAnYan Aug 7, 2024
43f1f7c
Fix for https://github.com/InAnYan/jabref/issues/126
InAnYan Aug 7, 2024
32c4943
Fix for https://github.com/InAnYan/jabref/issues/115
InAnYan Aug 7, 2024
1f3d20a
Fix for https://github.com/InAnYan/jabref/issues/113
InAnYan Aug 7, 2024
2d64d01
Fix for https://github.com/InAnYan/jabref/issues/91
InAnYan Aug 7, 2024
ef94344
Fix for https://github.com/InAnYan/jabref/issues/121
InAnYan Aug 7, 2024
9cfffe1
Merge branch 'main' into ai-pr-1
koppor Aug 7, 2024
718a859
Fix for https://github.com/InAnYan/jabref/issues/112 and https://gith…
InAnYan Aug 7, 2024
5ce5c2c
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 7, 2024
441308d
Fix for https://github.com/InAnYan/jabref/issues/125
InAnYan Aug 7, 2024
58196dd
Fixes from commit comments
InAnYan Aug 7, 2024
79acddf
Fix for https://github.com/InAnYan/jabref/issues/115
InAnYan Aug 7, 2024
72e90ad
Fix for https://github.com/InAnYan/jabref/issues/120
InAnYan Aug 7, 2024
8c93f0b
Fix for https://github.com/InAnYan/jabref/issues/132
InAnYan Aug 7, 2024
041d91b
Fix for https://github.com/InAnYan/jabref/issues/132
InAnYan Aug 7, 2024
8b7fff1
Fix for https://github.com/InAnYan/jabref/issues/104
InAnYan Aug 7, 2024
a38c439
Fix for https://github.com/InAnYan/jabref/issues/118
InAnYan Aug 7, 2024
b5aa552
Merge remote-tracking branch 'upstream/main' into ai-pr-1
koppor Aug 7, 2024
27f941b
Fix for https://github.com/InAnYan/jabref/issues/114
InAnYan Aug 9, 2024
cd41ab5
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 9, 2024
99fd54f
Fix for https://github.com/InAnYan/jabref/issues/104
InAnYan Aug 9, 2024
405798f
Store error messages in chat history
InAnYan Aug 9, 2024
1e9f5f8
Make error be a ChatMessageComponent
InAnYan Aug 9, 2024
e161e5e
Implement delete messages https://github.com/InAnYan/jabref/issues/136
InAnYan Aug 9, 2024
34fd37c
Fix for https://github.com/InAnYan/jabref/issues/118
InAnYan Aug 9, 2024
4cfeef0
Fix for https://github.com/InAnYan/jabref/issues/92
InAnYan Aug 9, 2024
a5ef15f
Fix checkstyle and localization. And refactoring
InAnYan Aug 9, 2024
80436e7
Fix for https://github.com/InAnYan/jabref/issues/92
InAnYan Aug 12, 2024
098bb68
Fix for https://github.com/InAnYan/jabref/issues/139
InAnYan Aug 12, 2024
f4ca7a4
Show "Delete message" button only when necessary
InAnYan Aug 12, 2024
72ff85d
Merge branch 'refs/heads/upstream-main' into ai-pr-1
InAnYan Aug 12, 2024
e8d5b47
Fix for https://github.com/InAnYan/jabref/issues/83
InAnYan Aug 12, 2024
8519eb3
Update src/main/java/org/jabref/logic/ai/AiService.java
InAnYan Aug 12, 2024
95cbc39
Update src/main/java/org/jabref/logic/ai/chathistory/BibDatabaseChatH…
InAnYan Aug 12, 2024
6df1a02
Update src/main/java/org/jabref/logic/ai/AiService.java
InAnYan Aug 12, 2024
0478348
Update src/main/java/org/jabref/gui/Base.css
InAnYan Aug 12, 2024
ef6fdab
Update src/main/java/org/jabref/gui/Base.css
InAnYan Aug 12, 2024
23ae468
Fix from code review
InAnYan Aug 12, 2024
8f28cc4
Partial fix for https://github.com/InAnYan/jabref/issues/125
InAnYan Aug 12, 2024
8217c9e
Update colors for error message
InAnYan Aug 12, 2024
93ea840
Fix for https://github.com/InAnYan/jabref/issues/145 and https://gith…
InAnYan Aug 12, 2024
f08eaea
Make progress for embedding model download
InAnYan Aug 12, 2024
8d7a77d
Merge branch 'main' into ai-pr-1
koppor Aug 12, 2024
1acadf3
Fix checkstyle and localization
InAnYan Aug 12, 2024
a633766
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 12, 2024
f3ffc54
Merge branch 'main' into ai-pr-1
koppor Aug 12, 2024
8ec3876
Add workaround to get FileHistoryMenuTest running again
koppor Aug 12, 2024
d6f9c3d
Merge branch 'main' into ai-pr-1
koppor Aug 12, 2024
85382a1
Small fixes
InAnYan Aug 13, 2024
bb46869
Merge remote-tracking branch 'upstream/ai-pr-1' into ai-pr-1
InAnYan Aug 13, 2024
9a15e6c
Merge branch 'main' into ai-pr-1
koppor Aug 13, 2024
9ff69a7
Revert "Small fixes"
koppor Aug 13, 2024
64f905e
Introduce AiApiKeyProvider
koppor Aug 13, 2024
8146ff0
Fix IDE setup instructions
koppor Aug 13, 2024
400d83e
Do not load API keys on startup
koppor Aug 13, 2024
7241929
Rely on keystore encryption
koppor Aug 13, 2024
2154a1e
Prevent mulitple rebuilds when muliple preferences are updated
koppor Aug 13, 2024
e18eda9
Fix localization to be more provider independent
koppor Aug 13, 2024
d3e8155
Fix method names
koppor Aug 13, 2024
26e279a
Add poor man's solution to notify of API key changes
koppor Aug 13, 2024
d4a96d0
Reduce calls to key store (and fix key saving)
koppor Aug 13, 2024
3c8cb68
Merge branch 'main' into ai-pr-1
koppor Aug 13, 2024
5fa3bb5
Fix for https://github.com/InAnYan/jabref/issues/148 and partially ht…
InAnYan Aug 14, 2024
58bdb8c
Revert "Fix for https://github.com/InAnYan/jabref/issues/148 and part…
InAnYan Aug 14, 2024
f794012
Fix for scrolling down when deleting a message
InAnYan Aug 14, 2024
9730fe8
Sort EmbeddingModel enum variants
InAnYan Aug 14, 2024
d0e7170
Fix GenerateSummaryTask progress indication
InAnYan Aug 14, 2024
8aa5fbb
Fix dark mode
InAnYan Aug 14, 2024
ddd979a
Add notice for embedding models size
InAnYan Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix bugs
  • Loading branch information
InAnYan committed May 27, 2024
commit 6cec13ae96b4bbc7502423e0d8070c8880da4430
8 changes: 7 additions & 1 deletion src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.jabref.gui.undo.CountingUndoManager;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.ai.AiService;
import org.jabref.logic.bibtex.TypedBibEntry;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.importer.EntryBasedFetcher;
Expand Down Expand Up @@ -88,6 +89,9 @@ public class EntryEditor extends BorderPane {
private final ExternalFilesEntryLinker fileLinker;
private final DirectoryMonitorManager directoryMonitorManager;

// TODO: Move this out.
private final AiService aiService;

private Subscription typeSubscription;

/*
Expand Down Expand Up @@ -132,6 +136,8 @@ public EntryEditor(LibraryTab libraryTab) {
.root(this)
.load();

this.aiService = new AiService(preferencesService.getAiPreferences());

this.entryEditorPreferences = preferencesService.getEntryEditorPreferences();
this.fileLinker = new ExternalFilesEntryLinker(preferencesService.getFilePreferences(), databaseContext, dialogService);

Expand Down Expand Up @@ -315,7 +321,7 @@ private List<EntryEditorTab> createTabs() {
entryEditorTabs.add(sourceTab);
entryEditorTabs.add(new LatexCitationsTab(databaseContext, preferencesService, dialogService, directoryMonitorManager));
entryEditorTabs.add(new FulltextSearchResultsTab(stateManager, preferencesService, dialogService, taskExecutor));
entryEditorTabs.add(new AiChatTab(preferencesService, databaseContext, taskExecutor));
entryEditorTabs.add(new AiChatTab(preferencesService, aiService, databaseContext, taskExecutor));

return entryEditorTabs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ public class AiChatTab extends EntryEditorTab {

private BibEntry currentBibEntry = null;

// TODO: Proper embeddings.
private EmbeddingStore<TextSegment> embeddingStore = null;

public AiChatTab(PreferencesService preferencesService, AiService aiService,
BibDatabaseContext bibDatabaseContext, TaskExecutor taskExecutor) {
this.filePreferences = preferencesService.getFilePreferences();
Expand Down Expand Up @@ -117,12 +114,12 @@ private void bindToCorrectEntry(BibEntry entry) {
}

private void createAiChat() {
aiChat = new AiChat(aiService, MetadataFilterBuilder.metadataKey("linkedFile").isIn(currentBibEntry.getFiles()));
aiChat = new AiChat(aiService, MetadataFilterBuilder.metadataKey("linkedFile").isIn(currentBibEntry.getFiles().stream().map(LinkedFile::getLink).toList()));
aiChat.setSystemMessage(QA_SYSTEM_MESSAGE);
}

private void ingestFiles(BibEntry entry) {
AiIngestor aiIngestor = new AiIngestor(embeddingStore, aiService.getEmbeddingModel());
AiIngestor aiIngestor = new AiIngestor(aiService.getEmbeddingStore(), aiService.getEmbeddingModel());
entry.getFiles().forEach(file -> {
aiIngestor.ingestLinkedFile(file, bibDatabaseContext, filePreferences);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jabref.model.database.BibDatabase;
import org.jabref.model.entry.BibEntry;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -41,7 +42,10 @@ private void readAiChatsFile(BibDatabase bibDatabase, Path databasePath) {
File chatFile = chatPath.toFile();
try {
InputStream inputStream = new FileInputStream(chatFile);

ObjectMapper objectMapper = new ObjectMapper();
// Jackson JSON adds an unknown field "typeLabel".
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
AiChatsFile aiChatFile = objectMapper.readValue(inputStream, AiChatsFile.class);
loadAiChatHistory(bibDatabase, aiChatFile);
} catch (FileNotFoundException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/logic/ai/AiIngestor.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public AiIngestor(EmbeddingStore<TextSegment> embeddingStore, EmbeddingModel emb
public void ingestLinkedFile(LinkedFile linkedFile, BibDatabaseContext bibDatabaseContext, FilePreferences filePreferences) {
Optional<Path> path = linkedFile.findIn(bibDatabaseContext, filePreferences);
if (path.isPresent()) {
ingestFile(path.get(), new Metadata().add("linkedFile", linkedFile));
ingestFile(path.get(), new Metadata().add("linkedFile", linkedFile.getLink()));
} else {
LOGGER.error("Could not find path for a linked file: " + linkedFile.getLink());
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/logic/ai/AiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class AiService {
private final EventBus eventBus = new EventBus();

public AiService(AiPreferences aiPreferences) {
if (aiPreferences.getEnableChatWithFiles() && !aiPreferences.getOpenAiToken().isEmpty()) {
setOpenAiToken(aiPreferences.getOpenAiToken());
}

EasyBind.listen(aiPreferences.enableChatWithFilesProperty(), (property, oldValue, newValue) -> {
if (newValue) {
if (!aiPreferences.getOpenAiToken().isEmpty()) {
Expand Down