From d483c23c81ae7c4da1cde9b2b6cbde2c8572fe5d Mon Sep 17 00:00:00 2001 From: Markus Klenke Date: Fri, 9 Feb 2024 22:48:19 +0000 Subject: [PATCH] Adds documentation to OllamaServerCaller --- .../core/models/request/OllamaServerCaller.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/amithkoujalgi/ollama4j/core/models/request/OllamaServerCaller.java b/src/main/java/io/github/amithkoujalgi/ollama4j/core/models/request/OllamaServerCaller.java index 47b8a34..6f9f27b 100644 --- a/src/main/java/io/github/amithkoujalgi/ollama4j/core/models/request/OllamaServerCaller.java +++ b/src/main/java/io/github/amithkoujalgi/ollama4j/core/models/request/OllamaServerCaller.java @@ -24,6 +24,9 @@ import io.github.amithkoujalgi.ollama4j.core.models.OllamaResult; import io.github.amithkoujalgi.ollama4j.core.utils.OllamaRequestBody; import io.github.amithkoujalgi.ollama4j.core.utils.Utils; +/** + * Abstract helperclass to call the ollama api server. + */ public abstract class OllamaServerCaller { private static final Logger LOG = LoggerFactory.getLogger(OllamaAPI.class); @@ -42,6 +45,15 @@ public abstract class OllamaServerCaller { protected abstract String getEndpointSuffix(); + /** + * Calls the api server on the given host and endpoint suffix asynchronously, aka waiting for the response. + * + * @param body POST body payload + * @return result answer given by the assistant + * @throws OllamaBaseException any response code than 200 has been returned + * @throws IOException in case the responseStream can not be read + * @throws InterruptedException in case the server is not reachable or network issues happen + */ public OllamaResult generateSync(OllamaRequestBody body) throws OllamaBaseException, IOException, InterruptedException{ // Create Request @@ -53,7 +65,7 @@ public abstract class OllamaServerCaller { .POST( body.getBodyPublisher()); HttpRequest request = requestBuilder.build(); - if (this.verbose) LOG.info("Asking model: " + body.getBodyPublisher()); + if (this.verbose) LOG.info("Asking model: " + body.toString()); HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream());