Compare commits

...

3 Commits

Author SHA1 Message Date
seeseemelk 62f3c3efa5 Stream only the new tokens, not the entire message 2024-05-27 16:56:26 +02:00
seeseemelk 613e152e7d Do not append to history 2024-05-27 16:53:01 +02:00
amithkoujalgi bb0785140b [maven-release-plugin] prepare for next development iteration 2024-05-20 14:55:02 +00:00
3 changed files with 3 additions and 12 deletions
+2 -2
View File
@@ -4,7 +4,7 @@
<groupId>io.github.amithkoujalgi</groupId>
<artifactId>ollama4j</artifactId>
<version>1.0.72</version>
<version>1.0.73-SNAPSHOT</version>
<name>Ollama4j</name>
<description>Java library for interacting with Ollama API.</description>
@@ -39,7 +39,7 @@
<connection>scm:git:git@github.com:amithkoujalgi/ollama4j.git</connection>
<developerConnection>scm:git:https://github.com/amithkoujalgi/ollama4j.git</developerConnection>
<url>https://github.com/amithkoujalgi/ollama4j</url>
<tag>v1.0.72</tag>
<tag>v1.0.16</tag>
</scm>
<build>
@@ -16,16 +16,10 @@ public class OllamaChatResult extends OllamaResult{
List<OllamaChatMessage> chatHistory) {
super(response, responseTime, httpStatusCode);
this.chatHistory = chatHistory;
appendAnswerToChatHistory(response);
}
public List<OllamaChatMessage> getChatHistory() {
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 String message = "";
public OllamaChatStreamObserver(OllamaStreamHandler streamHandler) {
this.streamHandler = streamHandler;
}
@@ -23,8 +21,7 @@ public class OllamaChatStreamObserver {
}
protected void handleCurrentResponsePart(OllamaChatResponseModel currentResponsePart){
message = message + currentResponsePart.getMessage().getContent();
streamHandler.accept(message);
streamHandler.accept(currentResponsePart.getMessage().getContent());
}