Skip to content

Instantly share code, notes, and snippets.

@incubated-geek-cc
Created March 28, 2024 18:23
Show Gist options
  • Save incubated-geek-cc/c86bbedf9a2649fe7d378fb1b15cdd7b to your computer and use it in GitHub Desktop.
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.
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