Skip to content

Commit

Permalink
Fix for #98
Browse files Browse the repository at this point in the history
  • Loading branch information
InAnYan committed Aug 6, 2024
1 parent 1d4c383 commit 547da5d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/main/java/org/jabref/preferences/AiPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,17 @@ public String getSelectedApiToken() {
}

public String getSelectedApiBaseUrl() {
return switch (aiProvider.get()) {
case OPEN_AI ->
openAiApiBaseUrl.get();
case MISTRAL_AI ->
mistralAiApiBaseUrl.get();
case HUGGING_FACE ->
huggingFaceApiBaseUrl.get();
};
if (customizeExpertSettings.get()) {
return switch (aiProvider.get()) {
case OPEN_AI ->
openAiApiBaseUrl.get();
case MISTRAL_AI ->
mistralAiApiBaseUrl.get();
case HUGGING_FACE ->
huggingFaceApiBaseUrl.get();
};
} else {
return AiDefaultPreferences.PROVIDERS_API_URLS.get(aiProvider.get());
}
}
}

2 comments on commit 547da5d

@koppor
Copy link
Collaborator

@koppor koppor commented on 547da5d Aug 6, 2024

Choose a reason for hiding this comment

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

I think, this is a good excercise to train map and orElseGet() of Optionals in Java.

@InAnYan
Copy link
Owner Author

@InAnYan InAnYan commented on 547da5d Aug 6, 2024

Choose a reason for hiding this comment

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

But those are not Optionals

Please sign in to comment.