mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-11-02 01:20:41 +01:00
Compare commits
8 Commits
v1.0.71
...
62f3c3efa5
| Author | SHA1 | Date | |
|---|---|---|---|
| 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:
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
4
pom.xml
4
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.73-SNAPSHOT</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>
|
||||||
|
|||||||
@@ -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