mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-05-15 20:07:10 +02:00
init
This commit is contained in:
parent
a3fa018fcc
commit
e7351359a3
@ -10,12 +10,11 @@ docker run -v ~/ollama:/root/.ollama -p 11434:11434 ollama/ollama
|
|||||||
Post a question to Ollama using Ollama4j:
|
Post a question to Ollama using Ollama4j:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
public class Main {
|
||||||
|
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.pullModel(OllamaModel.LLAMA2);
|
ollamaAPI.pullModel(OllamaModel.LLAMA2);
|
||||||
|
|
||||||
OllamaAsyncResultCallback ollamaAsyncResultCallback = ollamaAPI.runAsync(OllamaModel.LLAMA2, "Who are you?");
|
OllamaAsyncResultCallback ollamaAsyncResultCallback = ollamaAPI.runAsync(OllamaModel.LLAMA2, "Who are you?");
|
||||||
while (true) {
|
while (true) {
|
||||||
if (ollamaAsyncResultCallback.isComplete()) {
|
if (ollamaAsyncResultCallback.isComplete()) {
|
||||||
@ -24,6 +23,8 @@ while (true) {
|
|||||||
}
|
}
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
You'd then get a response from Ollama:
|
You'd then get a response from Ollama:
|
||||||
|
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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.ollama4j</groupId>
|
<groupId>io.github.amithkoujalgi</groupId>
|
||||||
<artifactId>ollama4j</artifactId>
|
<artifactId>ollama4j</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
@ -14,6 +14,29 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</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>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.ollama4j;
|
package io.github.amithkoujalgi.ollama4j;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) throws Exception {
|
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 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.classic.methods.HttpPost;
|
||||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
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;
|
import com.google.gson.Gson;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.ollama4j;
|
package io.github.amithkoujalgi.ollama4j;
|
||||||
|
|
||||||
public class OllamaBaseException extends Exception {
|
public class OllamaBaseException extends Exception {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.ollama4j;
|
package io.github.amithkoujalgi.ollama4j;
|
||||||
|
|
||||||
public enum OllamaModel {
|
public enum OllamaModel {
|
||||||
LLAMA2("llama2"), MISTRAL("mistral"), MEDLLAMA2("medllama2");
|
LLAMA2("llama2"), MISTRAL("mistral"), MEDLLAMA2("medllama2");
|
@ -1,4 +1,4 @@
|
|||||||
package org.ollama4j;
|
package io.github.amithkoujalgi.ollama4j;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.ollama4j;
|
package io.github.amithkoujalgi.ollama4j;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user