1package io.github.ollama4j.models.request;
3import com.fasterxml.jackson.core.JsonProcessingException;
4import io.github.ollama4j.exceptions.OllamaBaseException;
5import io.github.ollama4j.models.response.OllamaResult;
6import io.github.ollama4j.models.generate.OllamaGenerateResponseModel;
7import io.github.ollama4j.models.generate.OllamaGenerateStreamObserver;
8import io.github.ollama4j.models.generate.OllamaStreamHandler;
9import io.github.ollama4j.utils.OllamaRequestBody;
10import io.github.ollama4j.utils.Utils;
11import org.slf4j.Logger;
12import org.slf4j.LoggerFactory;
14import java.io.IOException;
23 super(host, basicAuth, requestTimeoutSeconds, verbose);
28 return "/api/generate";
35 responseBuffer.append(ollamaResponseModel.getResponse());
36 if (streamObserver !=
null) {
37 streamObserver.
notify(ollamaResponseModel);
39 return ollamaResponseModel.isDone();
40 }
catch (JsonProcessingException e) {
41 LOG.error(
"Error parsing the Ollama chat response!", e);
49 return super.callSync(body);
void notify(OllamaGenerateResponseModel currentResponsePart)
OllamaResult call(OllamaRequestBody body, OllamaStreamHandler streamHandler)
boolean parseResponseAndAddToBuffer(String line, StringBuilder responseBuffer)
OllamaGenerateEndpointCaller(String host, BasicAuth basicAuth, long requestTimeoutSeconds, boolean verbose)
String getEndpointSuffix()
static ObjectMapper getObjectMapper()