#178 - Add support for running local LLMs via LLaMA C/C++ port (#249)

* Initial implementation of integrating llama.cpp to run LLaMA models locally

* Move submodule

* Copy llama submodule to bundle

* Support for downloading models from IDE

* Code cleanup

* Store port field

* Replace service selection radio group with dropdown

* Add quantization support + other fixes

* Add option to override host

* Fix override host handler

* Disable port field when override host enabled

* Design updates

* Fix llama settings configuration, design changes, clean up code

* Improve You.com coupon design

* Add new Phind model and help tooltip

* Fetch you.com subscription

* Add CodeBooga model, fix downloadable model selection

* Chat history support

* Code refactoring, minor bug fixes

* UI updates, several bug fixes, removed code llama python model

* Code cleanup, enable llama port only on macOS

* Change downloaded gguf models path

* Move some of the labels to codegpt bundle

* Minor fixes

* Remove ToRA model, add help texts

* Fix test

* Modify description
This commit is contained in:
Carl-Robert 2023-11-03 12:00:24 +02:00 committed by GitHub
parent ca2eb9b6fa
commit 45908e69df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 2748 additions and 533 deletions

View file

@ -0,0 +1,96 @@
package ee.carlrobert.codegpt.settings.state;
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 com.intellij.util.xmlb.XmlSerializerUtil;
import ee.carlrobert.codegpt.completions.HuggingFaceModel;
import ee.carlrobert.codegpt.completions.llama.PromptTemplate;
import java.io.IOException;
import java.net.ServerSocket;
import org.jetbrains.annotations.NotNull;
@State(name = "CodeGPT_LlamaSettings", storages = @Storage("CodeGPT_CodeGPT_LlamaSettings.xml"))
public class LlamaSettingsState implements PersistentStateComponent<LlamaSettingsState> {
private boolean useCustomModel;
private String customLlamaModelPath = "";
private HuggingFaceModel huggingFaceModel = HuggingFaceModel.CODE_LLAMA_7B_Q4;
private PromptTemplate promptTemplate = PromptTemplate.LLAMA;
private int serverPort = getRandomAvailablePortOrDefault();
private int contextSize = 2048;
public LlamaSettingsState() {
}
public static LlamaSettingsState getInstance() {
return ApplicationManager.getApplication().getService(LlamaSettingsState.class);
}
@Override
public LlamaSettingsState getState() {
return this;
}
@Override
public void loadState(@NotNull LlamaSettingsState state) {
XmlSerializerUtil.copyBean(state, this);
}
public boolean isUseCustomModel() {
return useCustomModel;
}
public void setUseCustomModel(boolean useCustomModel) {
this.useCustomModel = useCustomModel;
}
public String getCustomLlamaModelPath() {
return customLlamaModelPath;
}
public void setCustomLlamaModelPath(String customLlamaModelPath) {
this.customLlamaModelPath = customLlamaModelPath;
}
public HuggingFaceModel getHuggingFaceModel() {
return huggingFaceModel;
}
public void setHuggingFaceModel(HuggingFaceModel huggingFaceModel) {
this.huggingFaceModel = huggingFaceModel;
}
public PromptTemplate getPromptTemplate() {
return promptTemplate;
}
public void setPromptTemplate(PromptTemplate promptTemplate) {
this.promptTemplate = promptTemplate;
}
public int getServerPort() {
return serverPort;
}
public void setServerPort(int serverPort) {
this.serverPort = serverPort;
}
public int getContextSize() {
return contextSize;
}
public void setContextSize(int contextSize) {
this.contextSize = contextSize;
}
private static Integer getRandomAvailablePortOrDefault() {
try (ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();
} catch (IOException e) {
return 8080;
}
}
}