forked from Mirror/ollama4j
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 33ebd088c4 | |||
| caf632ec8b | |||
| 62f3c3efa5 | |||
| 613e152e7d | |||
|
|
bb0785140b | ||
|
|
e33ad1a1e3 | ||
|
|
cd60c506cb | ||
|
|
b55925df28 | ||
|
|
2866d83a2f | ||
|
|
45e5d07581 |
21
README.md
21
README.md
@@ -67,10 +67,29 @@ In your Maven project, add this dependency:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.amithkoujalgi</groupId>
|
<groupId>io.github.amithkoujalgi</groupId>
|
||||||
<artifactId>ollama4j</artifactId>
|
<artifactId>ollama4j</artifactId>
|
||||||
<version>1.0.57</version>
|
<version>1.0.70</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
In your Gradle project, add the dependency using the Kotlin DSL or the Groovy DSL:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
dependencies {
|
||||||
|
|
||||||
|
val ollama4jVersion = "1.0.70"
|
||||||
|
|
||||||
|
implementation("io.github.amithkoujalgi:ollama4j:$ollama4jVersion")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
dependencies {
|
||||||
|
implementation("io.github.amithkoujalgi:ollama4j:1.0.70")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Latest release:
|
Latest release:
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
19
pom.xml
19
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>io.github.amithkoujalgi</groupId>
|
<groupId>io.github.amithkoujalgi</groupId>
|
||||||
<artifactId>ollama4j</artifactId>
|
<artifactId>ollama4j</artifactId>
|
||||||
<version>1.0.71</version>
|
<version>1.0.72-1</version>
|
||||||
|
|
||||||
<name>Ollama4j</name>
|
<name>Ollama4j</name>
|
||||||
<description>Java library for interacting with Ollama API.</description>
|
<description>Java library for interacting with Ollama API.</description>
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
<connection>scm:git:git@github.com:amithkoujalgi/ollama4j.git</connection>
|
<connection>scm:git:git@github.com:amithkoujalgi/ollama4j.git</connection>
|
||||||
<developerConnection>scm:git:https://github.com/amithkoujalgi/ollama4j.git</developerConnection>
|
<developerConnection>scm:git:https://github.com/amithkoujalgi/ollama4j.git</developerConnection>
|
||||||
<url>https://github.com/amithkoujalgi/ollama4j</url>
|
<url>https://github.com/amithkoujalgi/ollama4j</url>
|
||||||
<tag>v1.0.71</tag>
|
<tag>v1.0.16</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -139,6 +139,13 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>gitea</id>
|
||||||
|
<url>https://gitea.seeseepuff.be/api/packages/seeseemelk/maven</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
@@ -189,12 +196,12 @@
|
|||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<snapshotRepository>
|
<snapshotRepository>
|
||||||
<id>ossrh</id>
|
<id>gitea</id>
|
||||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://gitea.seeseepuff.be/api/packages/seeseemelk/maven</url>
|
||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>ossrh</id>
|
<id>gitea</id>
|
||||||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2</url>
|
<url>https://gitea.seeseepuff.be/api/packages/seeseemelk/maven</url>
|
||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
|
|||||||
@@ -16,17 +16,11 @@ public class OllamaChatResult extends OllamaResult{
|
|||||||
List<OllamaChatMessage> chatHistory) {
|
List<OllamaChatMessage> chatHistory) {
|
||||||
super(response, responseTime, httpStatusCode);
|
super(response, responseTime, httpStatusCode);
|
||||||
this.chatHistory = chatHistory;
|
this.chatHistory = chatHistory;
|
||||||
appendAnswerToChatHistory(response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OllamaChatMessage> getChatHistory() {
|
public List<OllamaChatMessage> getChatHistory() {
|
||||||
return chatHistory;
|
return chatHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendAnswerToChatHistory(String answer){
|
|
||||||
OllamaChatMessage assistantMessage = new OllamaChatMessage(OllamaChatMessageRole.ASSISTANT, answer);
|
|
||||||
this.chatHistory.add(assistantMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ public class OllamaChatStreamObserver {
|
|||||||
|
|
||||||
private List<OllamaChatResponseModel> responseParts = new ArrayList<>();
|
private List<OllamaChatResponseModel> responseParts = new ArrayList<>();
|
||||||
|
|
||||||
private String message = "";
|
|
||||||
|
|
||||||
public OllamaChatStreamObserver(OllamaStreamHandler streamHandler) {
|
public OllamaChatStreamObserver(OllamaStreamHandler streamHandler) {
|
||||||
this.streamHandler = streamHandler;
|
this.streamHandler = streamHandler;
|
||||||
}
|
}
|
||||||
@@ -23,8 +21,7 @@ public class OllamaChatStreamObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void handleCurrentResponsePart(OllamaChatResponseModel currentResponsePart){
|
protected void handleCurrentResponsePart(OllamaChatResponseModel currentResponsePart){
|
||||||
message = message + currentResponsePart.getMessage().getContent();
|
streamHandler.accept(currentResponsePart.getMessage().getContent());
|
||||||
streamHandler.accept(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user