mirror of
				https://github.com/amithkoujalgi/ollama4j.git
				synced 2025-10-31 08:30:41 +01:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			1.0.80
			...
			62f3c3efa5
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 62f3c3efa5 | |||
| 613e152e7d | 
| @@ -16,16 +16,10 @@ 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