forked from Mirror/ollama4j
init
This commit is contained in:
parent
a3fa018fcc
commit
e7351359a3
17
README.md
17
README.md
@ -10,19 +10,20 @@ docker run -v ~/ollama:/root/.ollama -p 11434:11434 ollama/ollama
|
||||
Post a question to Ollama using Ollama4j:
|
||||
|
||||
```java
|
||||
String host = "http://localhost:11434/";
|
||||
|
||||
OllamaAPI ollamaAPI = new OllamaAPI(host);
|
||||
|
||||
ollamaAPI.pullModel(OllamaModel.LLAMA2);
|
||||
|
||||
OllamaAsyncResultCallback ollamaAsyncResultCallback = ollamaAPI.runAsync(OllamaModel.LLAMA2, "Who are you?");
|
||||
while (true) {
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String host = "http://localhost:11434/";
|
||||
OllamaAPI ollamaAPI = new OllamaAPI(host);
|
||||
ollamaAPI.pullModel(OllamaModel.LLAMA2);
|
||||
OllamaAsyncResultCallback ollamaAsyncResultCallback = ollamaAPI.runAsync(OllamaModel.LLAMA2, "Who are you?");
|
||||
while (true) {
|
||||
if (ollamaAsyncResultCallback.isComplete()) {
|
||||
System.out.println(ollamaAsyncResultCallback.getResponse());
|
||||
break;
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
25
pom.xml
25
pom.xml
@ -4,7 +4,7 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.ollama4j</groupId>
|
||||
<groupId>io.github.amithkoujalgi</groupId>
|
||||
<artifactId>ollama4j</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
@ -14,6 +14,29 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Amith Koujalgi</name>
|
||||
<email>koujalgi.amith@gmail.com</email>
|
||||
<organization>Sonatype</organization>
|
||||
<organizationUrl>http://www.sonatype.com</organizationUrl>
|
||||
</developer>
|
||||
</developers>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>MIT License</name>
|
||||
<url>https://raw.githubusercontent.com/amithkoujalgi/ollama4j/main/LICENSE</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:amithkoujalgi/ollama4j.git</connection>
|
||||
<developerConnection>scm:git:ssh://github.com:amithkoujalgi/ollama4j.git</developerConnection>
|
||||
<url>https://github.com/amithkoujalgi/ollama4j/tree/main</url>
|
||||
</scm>
|
||||
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.ollama4j;
|
||||
package io.github.amithkoujalgi.ollama4j;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws Exception {
|
@ -1,7 +1,6 @@
|
||||
package org.ollama4j;
|
||||
package io.github.amithkoujalgi.ollama4j;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.hc.client5.http.HttpResponseException;
|
||||
import org.apache.hc.client5.http.classic.methods.HttpPost;
|
||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
@ -1,4 +1,4 @@
|
||||
package org.ollama4j;
|
||||
package io.github.amithkoujalgi.ollama4j;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.ollama4j;
|
||||
package io.github.amithkoujalgi.ollama4j;
|
||||
|
||||
public class OllamaBaseException extends Exception {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.ollama4j;
|
||||
package io.github.amithkoujalgi.ollama4j;
|
||||
|
||||
public enum OllamaModel {
|
||||
LLAMA2("llama2"), MISTRAL("mistral"), MEDLLAMA2("medllama2");
|
@ -1,4 +1,4 @@
|
||||
package org.ollama4j;
|
||||
package io.github.amithkoujalgi.ollama4j;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.ollama4j;
|
||||
package io.github.amithkoujalgi.ollama4j;
|
||||
|
||||
import java.util.List;
|
||||
|
Loading…
x
Reference in New Issue
Block a user