Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OllamaChatStreamObserver.java
Go to the documentation of this file.
1package io.github.ollama4j.models.chat;
2
3import io.github.ollama4j.models.generate.OllamaStreamHandler;
4
5import java.util.ArrayList;
6import java.util.List;
7
9
10 private OllamaStreamHandler streamHandler;
11
12 private List<OllamaChatResponseModel> responseParts = new ArrayList<>();
13
14 private String message = "";
15
17 this.streamHandler = streamHandler;
18 }
19
20 public void notify(OllamaChatResponseModel currentResponsePart) {
21 responseParts.add(currentResponsePart);
22 handleCurrentResponsePart(currentResponsePart);
23 }
24
25 protected void handleCurrentResponsePart(OllamaChatResponseModel currentResponsePart) {
26 message = message + currentResponsePart.getMessage().getContent();
27 streamHandler.accept(message);
28 }
29
30
31}
void handleCurrentResponsePart(OllamaChatResponseModel currentResponsePart)
void notify(OllamaChatResponseModel currentResponsePart)