Created
March 28, 2024 18:23
-
-
Save incubated-geek-cc/c86bbedf9a2649fe7d378fb1b15cdd7b to your computer and use it in GitHub Desktop.
Source code for ChatApplication.java entity class converted from Application.java.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gpt4all; | |
import com.hexadevlabs.gpt4all.LLModel; | |
import java.io.File; | |
import java.nio.file.Paths; | |
public class ChatApplication { | |
private LLModel model; | |
LLModel.GenerationConfig config; | |
public ChatApplication() { | |
String modelFilePath = System.getProperty("user.dir") + File.separator + "external" + File.separator + "ggml-gpt4all-j-v1.3-groovy.bin"; | |
model = new LLModel(Paths.get(modelFilePath)); | |
config = LLModel.config().withNPredict(4096).build(); | |
} | |
public String getResponse(String prompt) { | |
String fullGeneration = model.generate(prompt, config, true); | |
char c = 10; | |
fullGeneration=fullGeneration.substring(fullGeneration.indexOf(c)+1); | |
return fullGeneration; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment