Updated readme

This commit is contained in:
Amith Koujalgi 2023-11-09 11:55:00 +05:30
parent 2bdf0cc638
commit 1f28e61234
2 changed files with 16 additions and 3 deletions

View File

@ -169,7 +169,8 @@ public class Main {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String host = "http://localhost:11434/"; String host = "http://localhost:11434/";
OllamaAPI ollamaAPI = new OllamaAPI(host); OllamaAPI ollamaAPI = new OllamaAPI(host);
ollamaAPI.createModel("mycustommodel", "/path/to/modelfile/on/ollama-server"); ollamaAPI.setVerbose(false);
ollamaAPI.deleteModel("mycustommodel", true);
} }
} }
``` ```
@ -183,7 +184,7 @@ public class Main {
public static void main(String[] args) { public static void main(String[] args) {
String host = "http://localhost:11434/"; String host = "http://localhost:11434/";
OllamaAPI ollamaAPI = new OllamaAPI(host); OllamaAPI ollamaAPI = new OllamaAPI(host);
String response = ollamaAPI.runSync(OllamaModel.LLAMA2, "Who are you?"); String response = ollamaAPI.ask(OllamaModel.LLAMA2, "Who are you?");
System.out.println(response); System.out.println(response);
} }
} }
@ -196,7 +197,7 @@ public class Main {
public static void main(String[] args) { public static void main(String[] args) {
String host = "http://localhost:11434/"; String host = "http://localhost:11434/";
OllamaAPI ollamaAPI = new OllamaAPI(host); OllamaAPI ollamaAPI = new OllamaAPI(host);
OllamaAsyncResultCallback ollamaAsyncResultCallback = ollamaAPI.runAsync(OllamaModel.LLAMA2, "Who are you?"); OllamaAsyncResultCallback ollamaAsyncResultCallback = ollamaAPI.askAsync(OllamaModel.LLAMA2, "Who are you?");
while (true) { while (true) {
if (ollamaAsyncResultCallback.isComplete()) { if (ollamaAsyncResultCallback.isComplete()) {
System.out.println(ollamaAsyncResultCallback.getResponse()); System.out.println(ollamaAsyncResultCallback.getResponse());

View File

@ -4,14 +4,26 @@ public class Model {
private String name, modified_at, digest; private String name, modified_at, digest;
private Long size; private Long size;
/**
* Returns the model's tag. This includes model name and its version separated by a colon character `:`
* @return model tag
*/
public String getName() { public String getName() {
return name; return name;
} }
/**
* Returns the model name without its version
* @return model name
*/
public String getModelName() { public String getModelName() {
return name.split(":")[0]; return name.split(":")[0];
} }
/**
* Returns the model version without its name
* @return model version
*/
public String getModelVersion() { public String getModelVersion() {
return name.split(":")[1]; return name.split(":")[1];
} }