mirror of
				https://github.com/amithkoujalgi/ollama4j.git
				synced 2025-10-31 00:20:40 +01:00 
			
		
		
		
	Stream only the new tokens, not the entire message
This commit is contained in:
		| @@ -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()); | ||||
|     } | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user