From c7054325102c1286a59d326db3519e710930c9e5 Mon Sep 17 00:00:00 2001 From: amithkoujalgi Date: Sat, 30 Aug 2025 17:04:02 +0530 Subject: [PATCH] Increase model pull retry delay and attempts Raised the base delay for model pull retries from 1s to 3s and updated log output to show seconds instead of milliseconds. Also increased the number of retries for model pull in integration tests from 3 to 5 to improve robustness. --- src/main/java/io/github/ollama4j/OllamaAPI.java | 6 +++--- .../ollama4j/integrationtests/OllamaAPIIntegrationTest.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/ollama4j/OllamaAPI.java b/src/main/java/io/github/ollama4j/OllamaAPI.java index 82f1a5a..9e53a06 100644 --- a/src/main/java/io/github/ollama4j/OllamaAPI.java +++ b/src/main/java/io/github/ollama4j/OllamaAPI.java @@ -429,7 +429,7 @@ public class OllamaAPI { return; } int numberOfRetries = 0; - long baseDelayMillis = 1000L; // 1 second base delay + long baseDelayMillis = 3000L; // 1 second base delay while (numberOfRetries < numberOfRetriesForModelPull) { try { this.doPullModel(modelName); @@ -450,8 +450,8 @@ public class OllamaAPI { int attempt = currentRetry + 1; if (attempt < maxRetries) { long backoffMillis = baseDelayMillis * (1L << currentRetry); - logger.error("Failed to pull model {}, retrying in {} ms... (attempt {}/{})", - modelName, backoffMillis, attempt, maxRetries); + logger.error("Failed to pull model {}, retrying in {} s... (attempt {}/{})", + modelName, backoffMillis/1000, attempt, maxRetries); try { Thread.sleep(backoffMillis); } catch (InterruptedException ie) { diff --git a/src/test/java/io/github/ollama4j/integrationtests/OllamaAPIIntegrationTest.java b/src/test/java/io/github/ollama4j/integrationtests/OllamaAPIIntegrationTest.java index 3df94a2..494c845 100644 --- a/src/test/java/io/github/ollama4j/integrationtests/OllamaAPIIntegrationTest.java +++ b/src/test/java/io/github/ollama4j/integrationtests/OllamaAPIIntegrationTest.java @@ -75,7 +75,7 @@ class OllamaAPIIntegrationTest { } api.setRequestTimeoutSeconds(120); api.setVerbose(true); - api.setNumberOfRetriesForModelPull(3); + api.setNumberOfRetriesForModelPull(5); } @Test