forked from Mirror/ollama4j
Compare commits
No commits in common. "62f3c3efa533ef552c0b67e6d5435c87753352a1" and "bb0785140b808300d327ea793680f9c9dd145161" have entirely different histories.
62f3c3efa5
...
bb0785140b
@ -16,10 +16,16 @@ 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,6 +11,8 @@ public class OllamaChatStreamObserver {
|
||||
|
||||
private List<OllamaChatResponseModel> responseParts = new ArrayList<>();
|
||||
|
||||
private String message = "";
|
||||
|
||||
public OllamaChatStreamObserver(OllamaStreamHandler streamHandler) {
|
||||
this.streamHandler = streamHandler;
|
||||
}
|
||||
@ -21,7 +23,8 @@ public class OllamaChatStreamObserver {
|
||||
}
|
||||
|
||||
protected void handleCurrentResponsePart(OllamaChatResponseModel currentResponsePart){
|
||||
streamHandler.accept(currentResponsePart.getMessage().getContent());
|
||||
message = message + currentResponsePart.getMessage().getContent();
|
||||
streamHandler.accept(message);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user