Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class AiTabViewModel implements PreferenceTabViewModel {
private final ObjectProperty<EmbeddingModel> selectedEmbeddingModel = new SimpleObjectProperty<>();

private final StringProperty currentApiBaseUrl = new SimpleStringProperty();
private final BooleanProperty disableApiBaseUrl = new SimpleBooleanProperty(true); // {@link HuggingFaceChatModel} and {@link GoogleAiGeminiChatModel} doesn't support setting API base URL
private final BooleanProperty disableApiBaseUrl = new SimpleBooleanProperty(true); // {@link GoogleAiGeminiChatModel} doesn't support setting API base URL

private final StringProperty openAiApiBaseUrl = new SimpleStringProperty();
private final StringProperty mistralAiApiBaseUrl = new SimpleStringProperty();
Expand Down Expand Up @@ -138,7 +138,7 @@ public AiTabViewModel(CliPreferences preferences) {
this.selectedAiProvider.addListener((_, oldValue, newValue) -> {
List<String> models = AiDefaultPreferences.getAvailableModels(newValue);

disableApiBaseUrl.set(newValue == AiProvider.HUGGING_FACE || newValue == AiProvider.GEMINI);
disableApiBaseUrl.set(newValue == AiProvider.GEMINI);

// When we setAll on Hugging Face, models are empty, and currentChatModel become null.
// It becomes null because currentChatModel is bound to combobox, and this combobox becomes empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.chat.response.ChatResponse;
import dev.langchain4j.model.googleai.GoogleAiGeminiChatModel;
import dev.langchain4j.model.huggingface.HuggingFaceChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.mistralai.MistralAiChatModel;

/**
Expand Down Expand Up @@ -88,13 +88,16 @@ private void rebuild() {
.build()
);

case HUGGING_FACE -> // NOTE: {@link HuggingFaceChatModel} doesn't support API base url.
langchainChatModel = Optional.of(HuggingFaceChatModel
case HUGGING_FACE ->
langchainChatModel = Optional.of(OpenAiChatModel
.builder()
.accessToken(apiKey)
.modelId(aiPreferences.getSelectedChatModel())
.apiKey(apiKey)
.modelName(aiPreferences.getSelectedChatModel())
.temperature(aiPreferences.getTemperature())
.baseUrl(aiPreferences.getSelectedApiBaseUrl())
.timeout(Duration.ofMinutes(2))
.logRequests(true)
.logResponses(true)
.build()
);
}
Expand Down
2 changes: 1 addition & 1 deletion jablib/src/main/java/org/jabref/model/ai/AiProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public enum AiProvider implements Serializable {
OPEN_AI("OpenAI (or API compatible)", "https://api.openai.com/v1", "https://openai.com/policies/privacy-policy/"),
MISTRAL_AI("Mistral AI", "https://api.mistral.ai/v1", "https://mistral.ai/terms/#privacy-policy"),
GEMINI("Gemini", "https://generativelanguage.googleapis.com/v1beta/", "https://ai.google.dev/gemini-api/terms"),
HUGGING_FACE("Hugging Face", "https://huggingface.co/api", "https://huggingface.co/privacy"),
HUGGING_FACE("Hugging Face", "https://router.huggingface.co/v1", "https://huggingface.co/privacy"),
GPT4ALL("GPT4All", "http://localhost:4891/v1", "https://www.nomic.ai/gpt4all/legal/privacy-policy");

private final String label;
Expand Down