Skip to content

Commit

Permalink
Fix for InAnYan#83
Browse files Browse the repository at this point in the history
  • Loading branch information
InAnYan committed Aug 12, 2024
1 parent 72ff85d commit e8d5b47
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/preferences/ai/AiTab.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<children>
<Label alignment="BASELINE_CENTER" text="%API key" />
<CustomPasswordField fx:id="apiKeyTextField" HBox.hgrow="ALWAYS" />
<Button fx:id="apiTokenHelp" prefWidth="20.0" />
<Button fx:id="apiKeyHelp" prefWidth="20.0" />
</children>
<padding>
<Insets left="20.0"/>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/preferences/ai/AiTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class AiTab extends AbstractPreferenceTabView<AiTabViewModel> implements
@FXML private Button enableAiHelp;
@FXML private Button aiProviderHelp;
@FXML private Button chatModelHelp;
@FXML private Button apiTokenHelp;
@FXML private Button apiKeyHelp;
@FXML private Button apiBaseUrlHelp;
@FXML private Button embeddingModelHelp;
@FXML private Button instructionHelp;
Expand Down Expand Up @@ -201,7 +201,7 @@ public void initialize() {
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_ENABLE, dialogService, preferencesService.getFilePreferences()), enableAiHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_PROVIDER, dialogService, preferencesService.getFilePreferences()), aiProviderHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_CHAT_MODEL, dialogService, preferencesService.getFilePreferences()), chatModelHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_API_TOKEN, dialogService, preferencesService.getFilePreferences()), apiTokenHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_API_KEY, dialogService, preferencesService.getFilePreferences()), apiKeyHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_EMBEDDING_MODEL, dialogService, preferencesService.getFilePreferences()), embeddingModelHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_API_BASE_URL, dialogService, preferencesService.getFilePreferences()), apiBaseUrlHelp);
actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AI_INSTRUCTION, dialogService, preferencesService.getFilePreferences()), instructionHelp);
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/jabref/logic/ai/AiChatLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,11 @@ private void rebuildChain() {
}

private void setSystemMessage(String systemMessage) {
String newSystemMessage = augmentSystemMessage(systemMessage);
chatMemory.add(new SystemMessage(newSystemMessage));
chatMemory.add(new SystemMessage(augmentSystemMessage(systemMessage)));
}

private String augmentSystemMessage(String oldSystemMessage) {
return oldSystemMessage + "\n\n" + "Here is the paper you are analyzing: " + CanonicalBibEntry.getCanonicalRepresentation(entry);
private String augmentSystemMessage(String systemMessage) {
return systemMessage + "\n" + CanonicalBibEntry.getCanonicalRepresentation(entry);
}

public AiMessage execute(UserMessage message) {
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/org/jabref/logic/help/HelpFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ public enum HelpFile {
FIND_DUPLICATES("finding-sorting-and-cleaning-entries/findduplicates"),
SQL_DATABASE_MIGRATION("collaborative-work/sqldatabase/sqldatabasemigration"),
PUSH_TO_APPLICATION("cite/pushtoapplications"),
AI_ENABLE("ai"),
AI_PROVIDER("ai#what-is-an-ai-provider"),
AI_CHAT_MODEL("ai#chat-model"),
AI_API_TOKEN("ai#what-is-an-api-key"),
AI_API_BASE_URL("ai#api-base-url"),
AI_EMBEDDING_MODEL("ai#embedding-model"),
AI_INSTRUCTION("ai#instruction"),
AI_CONTEXT_WINDOW_SIZE("ai#context-window-size"),
AI_DOCUMENT_SPLITTER_CHUNK_SIZE("ai#document-splitter-chunk-size"),
AI_DOCUMENT_SPLITTER_OVERLAP_SIZE("ai#document-splitter-overlap-size"),
AI_RAG_MAX_RESULTS_COUNT("ai#retrieval-augmented-generation-maximum-results-count"),
AI_RAG_MIN_SCORE("ai#retrieval-augmented-generation-minimum-score");
AI_ENABLE("ai/ai-functionality"),
AI_PROVIDER("ai/ai-providers-and-api-keys#what-is-an-ai-provider"),
AI_CHAT_MODEL("ai/preferences"),
AI_API_KEY("ai/ai-providers-and-api-keys#what-is-an-api-key"),
AI_API_BASE_URL("ai/preferences#api-base-url"),
AI_EMBEDDING_MODEL("ai/preferences#embedding-model"),
AI_INSTRUCTION("ai/preferences#instruction"),
AI_CONTEXT_WINDOW_SIZE("ai/preferences#context-window-size"),
AI_DOCUMENT_SPLITTER_CHUNK_SIZE("ai/preferences#document-splitter-chunk-size"),
AI_DOCUMENT_SPLITTER_OVERLAP_SIZE("ai/preferences#document-splitter-overlap-size"),
AI_RAG_MAX_RESULTS_COUNT("ai/preferences#retrieval-augmented-generation-maximum-results-count"),
AI_RAG_MIN_SCORE("ai/preferences#retrieval-augmented-generation-minimum-score");

private final String pageName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SummariesStorageTest {
void setUp() {
mvStore = MVStore.open(tempDir.resolve("test.mv").toString());
bibPath = tempDir.resolve("test.bib");
summariesStorage = new SummariesStorage(Mockito.mock(AiPreferences.class), mvStore);
summariesStorage = new SummariesStorage(Mockito.mock(AiPreferences.class), mvStore);
}

private void reopen() {
Expand Down

0 comments on commit e8d5b47

Please sign in to comment.