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