Skip to content

lunb0213/OllamaUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

OllamaUtils

Example:

generate api:

String msg = "Hello Ollama!";
String result = null;
OllamaRequest qr = new OllamaRequest("http://localhost:11434", RequestWay.GENERATE);
GenerateRequestMap qrm = new GenerateRequestMap();
qrm.setPrompt(msg);
GenerateResultMap grm = qr.request(qrm, GenerateResultMap.class);

result = grm.getResponse();//LLM answer

chat api:

String msg = "Hello Ollama!";
String result = null;
OllamaRequest qr = new OllamaRequest("http://localhost:11434", RequestWay.CHAT);
ChatRequestMap crm = new ChatRequestMap();
crm.setPrompt(msg);
GenerateResultMap grm = qr.request(crm, ChatResultMap.class);

result = grm.getMassage().get(0).get("content");//LLM answer

RequestWay types:

  • GENERATE
  • CHAT

Referenced libraries

  • jackson 2.15.2
  • spring-webmvc 5.2.8 --- (Mainly used for HTTP requests, there should be a better solution)

About

Some interfaces make it easy to access the Ollama API in Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages