feat: add gemini 2.0 flash model and update model combobox menu ui

This commit is contained in:
carlrobertoh@gmail.com 2025-02-10 17:14:46 +00:00
parent 6461e1de79
commit 25151ee42e
3 changed files with 155 additions and 17 deletions

View file

@ -23,6 +23,8 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupListener;
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
import com.intellij.openapi.ui.popup.ListPopup;
import ee.carlrobert.codegpt.CodeGPTKeys;
import ee.carlrobert.codegpt.Icons;
@ -39,6 +41,8 @@ import ee.carlrobert.codegpt.settings.service.google.GoogleSettings;
import ee.carlrobert.codegpt.settings.service.llama.LlamaSettings;
import ee.carlrobert.codegpt.settings.service.ollama.OllamaSettings;
import ee.carlrobert.codegpt.settings.service.openai.OpenAISettings;
import ee.carlrobert.codegpt.toolwindow.ui.CodeGPTModelsListPopupAction;
import ee.carlrobert.codegpt.toolwindow.ui.ModelListPopup;
import ee.carlrobert.llm.client.google.models.GoogleModel;
import ee.carlrobert.llm.client.openai.completion.OpenAIChatCompletionModel;
import java.awt.Color;
@ -101,8 +105,16 @@ public class ModelComboBoxAction extends ComboBoxAction {
@Override
protected JBPopup createActionPopup(DefaultActionGroup group, @NotNull DataContext context,
@Nullable Runnable disposeCallback) {
ListPopup popup = (ListPopup) super.createActionPopup(group, context, disposeCallback);
@Nullable Runnable disposeCallback) {
ListPopup popup = new ModelListPopup(group, context);
if (disposeCallback != null) {
popup.addListener(new JBPopupListener() {
@Override
public void onClosed(@NotNull LightweightWindowEvent event) {
disposeCallback.run();
}
});
}
popup.setShowSubmenuOnHover(true);
return popup;
}
@ -323,13 +335,14 @@ public class ModelComboBoxAction extends ComboBoxAction {
}
private AnAction createCodeGPTModelAction(CodeGPTModel model, Presentation comboBoxPresentation) {
return createModelAction(CODEGPT, model.getName(), model.getIcon(), comboBoxPresentation,
() -> ApplicationManager.getApplication()
.getService(CodeGPTServiceSettings.class)
.getState()
.getChatCompletionSettings()
.setModel(model.getCode()));
return new CodeGPTModelsListPopupAction(model, comboBoxPresentation, () -> {
ApplicationManager.getApplication()
.getService(CodeGPTServiceSettings.class)
.getState()
.getChatCompletionSettings()
.setModel(model.getCode());
handleModelChange(CODEGPT);
});
}
private AnAction createOllamaModelAction(String model, Presentation comboBoxPresentation) {