diff --git a/src/main/java/com/devoxx/genie/chatmodel/openai/OpenAIChatModelFactory.java b/src/main/java/com/devoxx/genie/chatmodel/openai/OpenAIChatModelFactory.java index 6941548..58e0728 100644 --- a/src/main/java/com/devoxx/genie/chatmodel/openai/OpenAIChatModelFactory.java +++ b/src/main/java/com/devoxx/genie/chatmodel/openai/OpenAIChatModelFactory.java @@ -35,6 +35,10 @@ public ChatLanguageModel createChatModel(@NotNull ChatModel chatModel) { builder.baseUrl(DevoxxGenieStateService.getInstance().getCustomOpenAIUrl()); } + if (Strings.isNotBlank(DevoxxGenieStateService.getInstance().getCustomOpenAIModel())) { + builder.modelName(DevoxxGenieStateService.getInstance().getCustomOpenAIModel()); + } + return builder.build(); } @@ -51,6 +55,11 @@ public StreamingChatLanguageModel createStreamingChatModel(@NotNull ChatModel ch if (Strings.isNotBlank(DevoxxGenieStateService.getInstance().getCustomOpenAIUrl())) { builder.baseUrl(DevoxxGenieStateService.getInstance().getCustomOpenAIUrl()); } + + if (Strings.isNotBlank(DevoxxGenieStateService.getInstance().getCustomOpenAIModel())) { + builder.modelName(DevoxxGenieStateService.getInstance().getCustomOpenAIModel()); + } + return builder.build(); } diff --git a/src/main/java/com/devoxx/genie/service/LLMModelRegistryService.java b/src/main/java/com/devoxx/genie/service/LLMModelRegistryService.java index e09486f..558b25f 100644 --- a/src/main/java/com/devoxx/genie/service/LLMModelRegistryService.java +++ b/src/main/java/com/devoxx/genie/service/LLMModelRegistryService.java @@ -208,6 +208,18 @@ private void addOpenAiModels() { .contextWindow(128_000) .apiKeyUsed(true) .build()); + + String custom = "custom"; + models.put(ModelProvider.OpenAI.getName() + ":" + gpt4oMini, + LanguageModel.builder() + .provider(ModelProvider.OpenAI) + .modelName(custom) + .displayName("Custom Model") + .inputCost(0.15) + .outputCost(0.6) + .contextWindow(128_000) + .apiKeyUsed(true) + .build()); } private void addDeepInfraModels() { diff --git a/src/main/java/com/devoxx/genie/ui/settings/DevoxxGenieStateService.java b/src/main/java/com/devoxx/genie/ui/settings/DevoxxGenieStateService.java index 33ea095..6cb5b4f 100644 --- a/src/main/java/com/devoxx/genie/ui/settings/DevoxxGenieStateService.java +++ b/src/main/java/com/devoxx/genie/ui/settings/DevoxxGenieStateService.java @@ -77,6 +77,7 @@ public static DevoxxGenieStateService getInstance() { private String llamaCPPUrl = LLAMA_CPP_MODEL_URL; private String jlamaUrl = JLAMA_MODEL_URL; private String customOpenAIUrl = ""; + private String customOpenAIModel = ""; // Local LLM Providers private boolean isOllamaEnabled = true; @@ -87,6 +88,7 @@ public static DevoxxGenieStateService getInstance() { private boolean isLlamaCPPEnabled = true; private boolean isJlamaEnabled = true; private boolean isCustomOpenAIEnabled = false; + private boolean isCustomOpenAIModelEnabled = false; // Remote LLM Providers private boolean isOpenAIEnabled = false; diff --git a/src/main/java/com/devoxx/genie/ui/settings/llm/LLMProvidersComponent.java b/src/main/java/com/devoxx/genie/ui/settings/llm/LLMProvidersComponent.java index 51a946b..84215f0 100644 --- a/src/main/java/com/devoxx/genie/ui/settings/llm/LLMProvidersComponent.java +++ b/src/main/java/com/devoxx/genie/ui/settings/llm/LLMProvidersComponent.java @@ -32,6 +32,8 @@ public class LLMProvidersComponent extends AbstractSettingsComponent { @Getter private final JTextField customOpenAIUrlField = new JTextField(stateService.getCustomOpenAIUrl()); @Getter + private final JTextField customOpenAIModelField = new JTextField(stateService.getCustomOpenAIModel()); + @Getter private final JPasswordField openAIKeyField = new JPasswordField(stateService.getOpenAIKey()); @Getter private final JTextField azureOpenAIEndpointField = new JTextField(stateService.getAzureOpenAIEndpoint()); @@ -72,6 +74,8 @@ public class LLMProvidersComponent extends AbstractSettingsComponent { private final JCheckBox jlamaEnabledCheckBox = new JCheckBox("", stateService.isJlamaEnabled()); @Getter private final JCheckBox customOpenAIEnabledCheckBox = new JCheckBox("", stateService.isCustomOpenAIEnabled()); + @Getter + private final JCheckBox customOpenAIModelEnabledCheckBox = new JCheckBox("", stateService.isCustomOpenAIModelEnabled()); @Getter private final JCheckBox openAIEnabledCheckBox = new JCheckBox("", stateService.isOpenAIEnabled()); @@ -129,6 +133,7 @@ public JPanel createPanel() { addProviderSettingRow(panel, gbc, "JLama URL", jlamaEnabledCheckBox, createTextWithLinkButton(jlamaModelUrlField, "https://github.com/tjake/Jlama")); addProviderSettingRow(panel, gbc, "Custom OpenAI URL", customOpenAIEnabledCheckBox, customOpenAIUrlField); + addProviderSettingRow(panel, gbc, "Custom OpenAI Model", customOpenAIModelEnabledCheckBox, customOpenAIModelField); // Cloud LLM Providers section addSection(panel, gbc, "Cloud LLM Providers"); diff --git a/src/main/java/com/devoxx/genie/ui/settings/llm/LLMProvidersConfigurable.java b/src/main/java/com/devoxx/genie/ui/settings/llm/LLMProvidersConfigurable.java index 6de089f..881f881 100644 --- a/src/main/java/com/devoxx/genie/ui/settings/llm/LLMProvidersConfigurable.java +++ b/src/main/java/com/devoxx/genie/ui/settings/llm/LLMProvidersConfigurable.java @@ -71,6 +71,7 @@ public boolean isModified() { isModified |= isFieldModified(llmSettingsComponent.getJanModelUrlField(), stateService.getJanModelUrl()); isModified |= isFieldModified(llmSettingsComponent.getExoModelUrlField(), stateService.getExoModelUrl()); isModified |= isFieldModified(llmSettingsComponent.getCustomOpenAIUrlField(), stateService.getCustomOpenAIUrl()); + isModified |= isFieldModified(llmSettingsComponent.getCustomOpenAIModelField(), stateService.getCustomOpenAIModel()); isModified |= !stateService.getShowAzureOpenAIFields().equals(llmSettingsComponent.getEnableAzureOpenAICheckBox().isSelected()); isModified |= isFieldModified(llmSettingsComponent.getAzureOpenAIEndpointField(), stateService.getAzureOpenAIEndpoint()); @@ -118,6 +119,7 @@ public void apply() { settings.setLlamaCPPUrl(llmSettingsComponent.getLlamaCPPModelUrlField().getText()); settings.setJlamaUrl(llmSettingsComponent.getJlamaModelUrlField().getText()); settings.setCustomOpenAIUrl(llmSettingsComponent.getCustomOpenAIUrlField().getText()); + settings.setCustomOpenAIModel(llmSettingsComponent.getCustomOpenAIModelField().getText()); settings.setOpenAIKey(new String(llmSettingsComponent.getOpenAIKeyField().getPassword())); settings.setMistralKey(new String(llmSettingsComponent.getMistralApiKeyField().getPassword())); @@ -187,6 +189,7 @@ public void reset() { llmSettingsComponent.getLlamaCPPModelUrlField().setText(settings.getLlamaCPPUrl()); llmSettingsComponent.getJlamaModelUrlField().setText(settings.getJlamaUrl()); llmSettingsComponent.getCustomOpenAIUrlField().setText(settings.getCustomOpenAIUrl()); + llmSettingsComponent.getCustomOpenAIModelField().setText(settings.getCustomOpenAIModel()); llmSettingsComponent.getOpenAIKeyField().setText(settings.getOpenAIKey()); llmSettingsComponent.getMistralApiKeyField().setText(settings.getMistralKey());