mirror of
				https://github.com/amithkoujalgi/ollama4j.git
				synced 2025-11-04 02:20:50 +01:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			snyk-upgra
			...
			62f3c3efa5
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 62f3c3efa5 | |||
| 613e152e7d | 
@@ -16,17 +16,11 @@ 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());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user