Remove modelKeepAliveTime property and related code

Eliminated the modelKeepAliveTime field from OllamaAPI and OllamaChatRequest, along with its usage in integration tests and configuration. This streamlines configuration and request handling by removing an unused or deprecated parameter.
This commit is contained in:
Amith Koujalgi 2025-09-20 17:48:21 +05:30
parent d6f5b5c313
commit 5ef1ea906d
5 changed files with 3 additions and 15 deletions

View File

@ -92,10 +92,6 @@ public class OllamaAPI {
@SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"})
private int numberOfRetriesForModelPull = 0;
@Setter
@SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"})
private int modelKeepAliveTime = 0;
/**
* Instantiates the Ollama API with default Ollama host: <a
* href="http://localhost:11434">http://localhost:11434</a>

View File

@ -8,7 +8,6 @@
*/
package io.github.ollama4j.models.chat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.ollama4j.models.request.OllamaCommonRequest;
import io.github.ollama4j.tools.Tools;
import io.github.ollama4j.utils.OllamaRequestBody;
@ -33,9 +32,6 @@ public class OllamaChatRequest extends OllamaCommonRequest implements OllamaRequ
private boolean think;
@JsonProperty("keep_alive")
private int modelKeepAliveTime;
/**
* Controls whether tools are automatically executed.
* <p>

View File

@ -71,7 +71,6 @@ class OllamaAPIIntegrationTest {
// ... (no javadoc needed for private setup logic)
int requestTimeoutSeconds = 60;
int numberOfRetriesForModelPull = 5;
int modelKeepAliveTime = 0;
try {
String useExternalOllamaHostEnv = System.getenv("USE_EXTERNAL_OLLAMA_HOST");
@ -99,7 +98,6 @@ class OllamaAPIIntegrationTest {
Integer.parseInt(props.getProperty("REQUEST_TIMEOUT_SECONDS"));
numberOfRetriesForModelPull =
Integer.parseInt(props.getProperty("NUMBER_RETRIES_FOR_MODEL_PULL"));
modelKeepAliveTime = Integer.parseInt(props.getProperty("MODEL_KEEP_ALIVE_TIME"));
} else {
useExternalOllamaHost = Boolean.parseBoolean(useExternalOllamaHostEnv);
ollamaHost = ollamaHostEnv;
@ -136,7 +134,6 @@ class OllamaAPIIntegrationTest {
}
api.setRequestTimeoutSeconds(requestTimeoutSeconds);
api.setNumberOfRetriesForModelPull(numberOfRetriesForModelPull);
api.setModelKeepAliveTime(modelKeepAliveTime);
}
/**

View File

@ -146,7 +146,7 @@ public class TestChatRequestSerialization extends AbstractSerializationTest<Olla
OllamaChatRequest req = builder.withKeepAlive(expectedKeepAlive).build();
String jsonRequest = serialize(req);
assertEquals(
deserialize(jsonRequest, OllamaChatRequest.class).getKeepAlive(),
expectedKeepAlive);
expectedKeepAlive,
deserialize(jsonRequest, OllamaChatRequest.class).getKeepAlive());
}
}

View File

@ -1,5 +1,4 @@
USE_EXTERNAL_OLLAMA_HOST=true
OLLAMA_HOST=http://192.168.29.229:11434/
REQUEST_TIMEOUT_SECONDS=120
NUMBER_RETRIES_FOR_MODEL_PULL=3
MODEL_KEEP_ALIVE_TIME=0
NUMBER_RETRIES_FOR_MODEL_PULL=3