mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-10 03:59:43 +00:00
fix: Storing HuggingFaceModel by modelName instead of quantization only (#529)
This commit is contained in:
parent
33aa0e1065
commit
2dfb1b0800
4 changed files with 69 additions and 77 deletions
|
|
@ -4,46 +4,47 @@ import static java.lang.String.format;
|
|||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public enum HuggingFaceModel {
|
||||
|
||||
CODE_LLAMA_7B_Q3(7, 3, "CodeLlama-7B-Instruct-GGUF"),
|
||||
CODE_LLAMA_7B_Q4(7, 4, "CodeLlama-7B-Instruct-GGUF"),
|
||||
CODE_LLAMA_7B_Q5(7, 5, "CodeLlama-7B-Instruct-GGUF"),
|
||||
CODE_LLAMA_13B_Q3(13, 3, "CodeLlama-13B-Instruct-GGUF"),
|
||||
CODE_LLAMA_13B_Q4(13, 4, "CodeLlama-13B-Instruct-GGUF"),
|
||||
CODE_LLAMA_13B_Q5(13, 5, "CodeLlama-13B-Instruct-GGUF"),
|
||||
CODE_LLAMA_34B_Q3(34, 3, "CodeLlama-34B-Instruct-GGUF"),
|
||||
CODE_LLAMA_34B_Q4(34, 4, "CodeLlama-34B-Instruct-GGUF"),
|
||||
CODE_LLAMA_34B_Q5(34, 5, "CodeLlama-34B-Instruct-GGUF"),
|
||||
CODE_LLAMA_7B_Q3(7, 3, "codellama-7b-instruct.Q3_K_M.gguf"),
|
||||
CODE_LLAMA_7B_Q4(7, 4, "codellama-7b-instruct.Q4_K_M.gguf"),
|
||||
CODE_LLAMA_7B_Q5(7, 5, "codellama-7b-instruct.Q5_K_M.gguf"),
|
||||
CODE_LLAMA_13B_Q3(13, 3, "codellama-13b-instruct.Q3_K_M.gguf"),
|
||||
CODE_LLAMA_13B_Q4(13, 4, "codellama-13b-instruct.Q4_K_M.gguf"),
|
||||
CODE_LLAMA_13B_Q5(13, 5, "codellama-13b-instruct.Q5_K_M.gguf"),
|
||||
CODE_LLAMA_34B_Q3(34, 3, "codellama-34b-instruct.Q3_K_M.gguf"),
|
||||
CODE_LLAMA_34B_Q4(34, 4, "codellama-34b-instruct.Q4_K_M.gguf"),
|
||||
CODE_LLAMA_34B_Q5(34, 5, "codellama-34b-instruct.Q5_K_M.gguf"),
|
||||
|
||||
CODE_BOOGA_34B_Q3(34, 3, "CodeBooga-34B-v0.1-GGUF"),
|
||||
CODE_BOOGA_34B_Q4(34, 4, "CodeBooga-34B-v0.1-GGUF"),
|
||||
CODE_BOOGA_34B_Q5(34, 5, "CodeBooga-34B-v0.1-GGUF"),
|
||||
CODE_BOOGA_34B_Q3(34, 3, "codebooga-34b-v0.1.Q3_K_M.gguf"),
|
||||
CODE_BOOGA_34B_Q4(34, 4, "codebooga-34b-v0.1.Q4_K_M.gguf"),
|
||||
CODE_BOOGA_34B_Q5(34, 5, "codebooga-34b-v0.1.Q5_K_M.gguf"),
|
||||
|
||||
DEEPSEEK_CODER_1_3B_Q3(1, 3, "deepseek-coder-1.3b-instruct-GGUF", 0.705),
|
||||
DEEPSEEK_CODER_1_3B_Q4(1, 4, "deepseek-coder-1.3b-instruct-GGUF", 0.874),
|
||||
DEEPSEEK_CODER_1_3B_Q5(1, 5, "deepseek-coder-1.3b-instruct-GGUF", 1.0),
|
||||
DEEPSEEK_CODER_6_7B_Q3(7, 3, "deepseek-coder-6.7b-instruct-GGUF"),
|
||||
DEEPSEEK_CODER_6_7B_Q4(7, 4, "deepseek-coder-6.7b-instruct-GGUF"),
|
||||
DEEPSEEK_CODER_6_7B_Q5(7, 5, "deepseek-coder-6.7b-instruct-GGUF"),
|
||||
DEEPSEEK_CODER_33B_Q3(33, 3, "deepseek-coder-33b-instruct-GGUF", 16.1),
|
||||
DEEPSEEK_CODER_33B_Q4(33, 4, "deepseek-coder-33b-instruct-GGUF", 19.9),
|
||||
DEEPSEEK_CODER_33B_Q5(33, 5, "deepseek-coder-33b-instruct-GGUF", 23.5),
|
||||
DEEPSEEK_CODER_1_3B_Q3(1, 3, "deepseek-coder-1.3b-instruct.Q3_K_M.gguf", 0.705),
|
||||
DEEPSEEK_CODER_1_3B_Q4(1, 4, "deepseek-coder-1.3b-instruct.Q4_K_M.gguf", 0.874),
|
||||
DEEPSEEK_CODER_1_3B_Q5(1, 5, "deepseek-coder-1.3b-instruct.Q5_K_M.gguf", 1.0),
|
||||
DEEPSEEK_CODER_6_7B_Q3(7, 3, "deepseek-coder-6.7b-instruct.Q3_K_M.gguf"),
|
||||
DEEPSEEK_CODER_6_7B_Q4(7, 4, "deepseek-coder-6.7b-instruct.Q4_K_M.gguf"),
|
||||
DEEPSEEK_CODER_6_7B_Q5(7, 5, "deepseek-coder-6.7b-instruct.Q5_K_M.gguf"),
|
||||
DEEPSEEK_CODER_33B_Q3(33, 3, "deepseek-coder-33b-instruct.Q3_K_M.gguf", 16.1),
|
||||
DEEPSEEK_CODER_33B_Q4(33, 4, "deepseek-coder-33b-instruct.Q4_K_M.gguf", 19.9),
|
||||
DEEPSEEK_CODER_33B_Q5(33, 5, "deepseek-coder-33b-instruct.Q5_K_M.gguf", 23.5),
|
||||
|
||||
PHIND_CODE_LLAMA_34B_Q3(34, 3, "Phind-CodeLlama-34B-v2-GGUF"),
|
||||
PHIND_CODE_LLAMA_34B_Q4(34, 4, "Phind-CodeLlama-34B-v2-GGUF"),
|
||||
PHIND_CODE_LLAMA_34B_Q5(34, 5, "Phind-CodeLlama-34B-v2-GGUF"),
|
||||
PHIND_CODE_LLAMA_34B_Q3(34, 3, "phind-codellama-34b-v2.Q3_K_M.gguf"),
|
||||
PHIND_CODE_LLAMA_34B_Q4(34, 4, "phind-codellama-34b-v2.Q4_K_M.gguf"),
|
||||
PHIND_CODE_LLAMA_34B_Q5(34, 5, "phind-codellama-34b-v2.Q5_K_M.gguf"),
|
||||
|
||||
WIZARD_CODER_PYTHON_7B_Q3(7, 3, "WizardCoder-Python-7B-V1.0-GGUF"),
|
||||
WIZARD_CODER_PYTHON_7B_Q4(7, 4, "WizardCoder-Python-7B-V1.0-GGUF"),
|
||||
WIZARD_CODER_PYTHON_7B_Q5(7, 5, "WizardCoder-Python-7B-V1.0-GGUF"),
|
||||
WIZARD_CODER_PYTHON_13B_Q3(13, 3, "WizardCoder-Python-13B-V1.0-GGUF"),
|
||||
WIZARD_CODER_PYTHON_13B_Q4(13, 4, "WizardCoder-Python-13B-V1.0-GGUF"),
|
||||
WIZARD_CODER_PYTHON_13B_Q5(13, 5, "WizardCoder-Python-13B-V1.0-GGUF"),
|
||||
WIZARD_CODER_PYTHON_34B_Q3(34, 3, "WizardCoder-Python-34B-V1.0-GGUF"),
|
||||
WIZARD_CODER_PYTHON_34B_Q4(34, 4, "WizardCoder-Python-34B-V1.0-GGUF"),
|
||||
WIZARD_CODER_PYTHON_34B_Q5(34, 5, "WizardCoder-Python-34B-V1.0-GGUF"),
|
||||
WIZARD_CODER_PYTHON_7B_Q3(7, 3, "wizardcoder-python-7b-v1.0.Q3_K_M.gguf"),
|
||||
WIZARD_CODER_PYTHON_7B_Q4(7, 4, "wizardcoder-python-7b-v1.0.Q4_K_M.gguf"),
|
||||
WIZARD_CODER_PYTHON_7B_Q5(7, 5, "wizardcoder-python-7b-v1.0.Q5_K_M.gguf"),
|
||||
WIZARD_CODER_PYTHON_13B_Q3(13, 3, "wizardcoder-python-13b-v1.0.Q3_K_M.gguf"),
|
||||
WIZARD_CODER_PYTHON_13B_Q4(13, 4, "wizardcoder-python-13b-v1.0.Q4_K_M.gguf"),
|
||||
WIZARD_CODER_PYTHON_13B_Q5(13, 5, "wizardcoder-python-13b-v1.0.Q5_K_M.gguf"),
|
||||
WIZARD_CODER_PYTHON_34B_Q3(34, 3, "wizardcoder-python-34b-v1.0.Q3_K_M.gguf"),
|
||||
WIZARD_CODER_PYTHON_34B_Q4(34, 4, "wizardcoder-python-34b-v1.0.Q4_K_M.gguf"),
|
||||
WIZARD_CODER_PYTHON_34B_Q5(34, 5, "wizardcoder-python-34b-v1.0.Q5_K_M.gguf"),
|
||||
|
||||
LLAMA_3_8B_IQ3_M(8, 3, "Meta-Llama-3-8B-Instruct-IQ3_M.gguf", "lmstudio-community", 3.78),
|
||||
LLAMA_3_8B_Q4_K_M(8, 4, "Meta-Llama-3-8B-Instruct-Q4_K_M.gguf", "lmstudio-community", 4.92),
|
||||
|
|
@ -56,30 +57,12 @@ public enum HuggingFaceModel {
|
|||
|
||||
PHI_3_3_8B_4K_IQ4_NL(4, 4, "Phi-3-mini-4k-instruct-IQ4_NL.gguf", "lmstudio-community", 2.18),
|
||||
PHI_3_3_8B_4K_Q5_K_M(4, 5, "Phi-3-mini-4k-instruct-Q5_K_M.gguf", "lmstudio-community", 2.64),
|
||||
PHI_3_3_8B_4K_Q5_K_S(4, 5, "Phi-3-mini-4k-instruct-Q5_K_S.gguf", "lmstudio-community", 2.82),
|
||||
PHI_3_3_8B_4K_Q6_K(4, 6, "Phi-3-mini-4k-instruct-Q6_K.gguf", "lmstudio-community", 3.14),
|
||||
PHI_3_3_8B_4K_Q8_0(4, 8, "Phi-3-mini-4k-instruct-Q8_0.gguf", "lmstudio-community", 4.06),
|
||||
PHI_3_3_8B_4K_FP16(4, 16, "Phi-3-mini-4k-instruct-fp16.gguf", "lmstudio-community", 7.64),
|
||||
|
||||
CODE_GEMMA_7B_IQ1_S(7, 1, "codegemma-7b-it-IQ1_S.gguf", "lmstudio-community", 2.16),
|
||||
CODE_GEMMA_7B_IQ1_M(7, 1, "codegemma-7b-it-IQ1_M.gguf", "lmstudio-community", 2.32),
|
||||
CODE_GEMMA_7B_IQ2_XXS(7, 2, "codegemma-7b-it-IQ2_XXS.gguf", "lmstudio-community", 2.59),
|
||||
CODE_GEMMA_7B_IQ2_XS(7, 2, "codegemma-7b-it-IQ2_XS.gguf", "lmstudio-community", 2.81),
|
||||
CODE_GEMMA_7B_IQ2_S(7, 2, "codegemma-7b-it-IQ2_S.gguf", "lmstudio-community", 2.92),
|
||||
CODE_GEMMA_7B_IQ2_M(7, 2, "codegemma-7b-it-IQ2_M.gguf", "lmstudio-community", 3.13),
|
||||
CODE_GEMMA_7B_Q2_K(7, 2, "codegemma-7b-it-Q2_K.gguf", "lmstudio-community", 3.48),
|
||||
CODE_GEMMA_7B_IQ3_XXS(7, 3, "codegemma-7b-it-IQ3_XXS.gguf", "lmstudio-community", 3.49),
|
||||
CODE_GEMMA_7B_IQ3_XS(7, 3, "codegemma-7b-it-IQ3_XS.gguf", "lmstudio-community", 3.80),
|
||||
CODE_GEMMA_7B_IQ3_S(7, 3, "codegemma-7b-it-IQ3_S.gguf", "lmstudio-community", 3.98),
|
||||
CODE_GEMMA_7B_Q3_K_S(7, 3, "codegemma-7b-it-Q3_K_S.gguf", "lmstudio-community", 3.98),
|
||||
CODE_GEMMA_7B_IQ3_M(7, 3, "codegemma-7b-it-IQ3_M.gguf", "lmstudio-community", 4.11),
|
||||
CODE_GEMMA_7B_Q3_K_M(7, 3, "codegemma-7b-it-Q3_K_M.gguf", "lmstudio-community", 4.37),
|
||||
CODE_GEMMA_7B_Q3_K_L(7, 3, "codegemma-7b-it-Q3_K_L.gguf", "lmstudio-community", 4.71),
|
||||
CODE_GEMMA_7B_IQ4_XS(7, 4, "codegemma-7b-it-IQ4_XS.gguf", "lmstudio-community", 4.77),
|
||||
CODE_GEMMA_7B_IQ4_NL(7, 4, "codegemma-7b-it-IQ4_NL.gguf", "lmstudio-community", 5.01),
|
||||
CODE_GEMMA_7B_Q4_K_S(7, 4, "codegemma-7b-it-Q4_K_S.gguf", "lmstudio-community", 5.05),
|
||||
CODE_GEMMA_7B_Q4_K_M(7, 4, "codegemma-7b-it-Q4_K_M.gguf", "lmstudio-community", 5.33),
|
||||
CODE_GEMMA_7B_Q5_K_S(7, 5, "codegemma-7b-it-Q5_K_S.gguf", "lmstudio-community", 5.98),
|
||||
CODE_GEMMA_7B_Q5_K_M(7, 5, "codegemma-7b-it-Q5_K_M.gguf", "lmstudio-community", 6.14),
|
||||
CODE_GEMMA_7B_Q6_K(7, 6, "codegemma-7b-it-Q6_K.gguf", "lmstudio-community", 7.01),
|
||||
CODE_GEMMA_7B_Q8_0(7, 8, "codegemma-7b-it-Q8_0.gguf", "lmstudio-community", 9.08),
|
||||
|
|
@ -149,15 +132,15 @@ public enum HuggingFaceModel {
|
|||
}
|
||||
|
||||
private String getDirectory() {
|
||||
if ("lmstudio-community".equals(user)) {
|
||||
// Meta-Llama-3-8B-Instruct-Q4_K_M.gguf -> Meta-Llama-3-8B-Instruct-GGUF
|
||||
return modelName.replaceFirst("-[^.-]+\\.gguf$", "-GGUF");
|
||||
}
|
||||
return modelName;
|
||||
return modelName.replaceFirst("-[^.-]+\\.gguf$", "-GGUF");
|
||||
}
|
||||
|
||||
public String getQuantizationLabel() {
|
||||
return format("%d-bit precision", quantization);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return format("%d-bit precision", quantization);
|
||||
return modelName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ public enum LlamaModel {
|
|||
List.of(
|
||||
HuggingFaceModel.PHI_3_3_8B_4K_IQ4_NL,
|
||||
HuggingFaceModel.PHI_3_3_8B_4K_Q5_K_M,
|
||||
HuggingFaceModel.PHI_3_3_8B_4K_Q5_K_S,
|
||||
HuggingFaceModel.PHI_3_3_8B_4K_Q6_K,
|
||||
HuggingFaceModel.PHI_3_3_8B_4K_Q8_0,
|
||||
HuggingFaceModel.PHI_3_3_8B_4K_FP16)),
|
||||
|
|
@ -123,25 +122,8 @@ public enum LlamaModel {
|
|||
PromptTemplate.CODE_GEMMA,
|
||||
InfillPromptTemplate.CODE_GEMMA,
|
||||
List.of(
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ1_S,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ1_M,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ2_XXS,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ2_XS,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ2_S,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ2_M,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_Q2_K,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ3_XXS,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ3_XS,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ3_S,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_Q3_K_S,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ3_M,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_Q3_K_M,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_Q3_K_L,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ4_XS,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_IQ4_NL,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_Q4_K_S,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_Q4_K_M,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_Q5_K_S,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_Q5_K_M,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_Q6_K,
|
||||
HuggingFaceModel.CODE_GEMMA_7B_Q8_0)),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.intellij.openapi.application.ApplicationManager;
|
|||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import ee.carlrobert.codegpt.codecompletions.InfillPromptTemplate;
|
||||
import ee.carlrobert.codegpt.completions.HuggingFaceModel;
|
||||
import ee.carlrobert.codegpt.completions.llama.LlamaModel;
|
||||
import ee.carlrobert.codegpt.credentials.CredentialsStore;
|
||||
import ee.carlrobert.codegpt.settings.service.llama.form.LlamaSettingsForm;
|
||||
|
|
@ -26,6 +28,17 @@ public class LlamaSettings implements PersistentStateComponent<LlamaSettingsStat
|
|||
@Override
|
||||
public void loadState(@NotNull LlamaSettingsState state) {
|
||||
this.state = state;
|
||||
// Catch if model's name has changed which could lead to
|
||||
// HuggingFaceModel or PromptTemplates not being found
|
||||
if (this.state.getHuggingFaceModel() == null) {
|
||||
this.state.setHuggingFaceModel(HuggingFaceModel.CODE_LLAMA_7B_Q4);
|
||||
}
|
||||
if (this.state.getRemoteModelInfillPromptTemplate() == null) {
|
||||
this.state.setRemoteModelInfillPromptTemplate(InfillPromptTemplate.LLAMA);
|
||||
}
|
||||
if (this.state.getLocalModelPromptTemplate() == null) {
|
||||
this.state.setLocalModelInfillPromptTemplate(InfillPromptTemplate.LLAMA);
|
||||
}
|
||||
}
|
||||
|
||||
public static LlamaSettingsState getCurrentState() {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import ee.carlrobert.codegpt.settings.service.llama.LlamaSettings;
|
|||
import ee.carlrobert.codegpt.settings.service.llama.LlamaSettingsState;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.io.File;
|
||||
|
|
@ -41,6 +42,8 @@ import javax.swing.Box;
|
|||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -106,7 +109,7 @@ public class LlamaModelPreferencesForm {
|
|||
huggingFaceComboBoxModel),
|
||||
BorderLayout.WEST);
|
||||
modelDetailsLabel = new JBLabel();
|
||||
huggingFaceModelComboBox = createHuggingFaceComboBox(
|
||||
huggingFaceModelComboBox = createModelQuantizationComboBox(
|
||||
huggingFaceComboBoxModel,
|
||||
modelExistsIcon,
|
||||
modelDetailsLabel,
|
||||
|
|
@ -365,7 +368,7 @@ public class LlamaModelPreferencesForm {
|
|||
return comboBox;
|
||||
}
|
||||
|
||||
private ComboBox<HuggingFaceModel> createHuggingFaceComboBox(
|
||||
private ComboBox<HuggingFaceModel> createModelQuantizationComboBox(
|
||||
DefaultComboBoxModel<HuggingFaceModel> huggingFaceComboBoxModel,
|
||||
JBLabel modelExistsIcon,
|
||||
JBLabel modelDetailsLabel,
|
||||
|
|
@ -380,6 +383,17 @@ public class LlamaModelPreferencesForm {
|
|||
modelExistsIcon.setVisible(modelExists);
|
||||
downloadModelActionLinkWrapper.setVisible(!modelExists);
|
||||
});
|
||||
comboBox.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
Object item = value;
|
||||
if (item instanceof HuggingFaceModel) {
|
||||
item = ((HuggingFaceModel) item).getQuantizationLabel();
|
||||
}
|
||||
return super.getListCellRendererComponent(list, item, index, isSelected, cellHasFocus);
|
||||
}
|
||||
});
|
||||
return comboBox;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue