diff --git a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaChatClient.java b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaChatClient.java index 00e902ccdff..26ef069badf 100644 --- a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaChatClient.java +++ b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaChatClient.java @@ -174,10 +174,6 @@ OllamaApi.ChatRequest ollamaChatRequest(Prompt prompt, boolean stream) { requestBuilder.withKeepAlive(mergedOptions.getKeepAlive()); } - if (mergedOptions.getTemplate() != null) { - requestBuilder.withTemplate(mergedOptions.getTemplate()); - } - return requestBuilder.build(); } diff --git a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java index 709aeac005f..b5fee757995 100644 --- a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java +++ b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java @@ -416,7 +416,6 @@ public Message build() { * @param format The format to return the response in. Currently, the only accepted * value is "json". * @param keepAlive The duration to keep the model loaded in ollama while idle. https://pkg.go.dev/time#ParseDuration - * @param template The prompt template (overrides what is defined in the Modelfile). * @param options Additional model parameters. You can use the {@link OllamaOptions} builder * to create the options then {@link OllamaOptions#toMap()} to convert the options into a * map. @@ -428,7 +427,6 @@ public record ChatRequest( @JsonProperty("stream") Boolean stream, @JsonProperty("format") String format, @JsonProperty("keep_alive") String keepAlive, - @JsonProperty("template") String template, @JsonProperty("options") Map options) { public static Builder builder(String model) { @@ -442,7 +440,6 @@ public static class Builder { private boolean stream = false; private String format; private String keepAlive; - private String template; private Map options = Map.of(); public Builder(String model) { @@ -470,11 +467,6 @@ public Builder withKeepAlive(String keepAlive) { return this; } - public Builder withTemplate(String template) { - this.template = template; - return this; - } - public Builder withOptions(Map options) { Objects.requireNonNull(options, "The options can not be null."); @@ -489,7 +481,7 @@ public Builder withOptions(OllamaOptions options) { } public ChatRequest build() { - return new ChatRequest(model, messages, stream, format, keepAlive, template, options); + return new ChatRequest(model, messages, stream, format, keepAlive, options); } } } diff --git a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaOptions.java b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaOptions.java index 88199ac048f..660f4b3d0f1 100644 --- a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaOptions.java +++ b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaOptions.java @@ -45,7 +45,7 @@ public class OllamaOptions implements ChatOptions, EmbeddingOptions { public static final String DEFAULT_MODEL = OllamaModel.MISTRAL.id(); - private static final List NON_SUPPORTED_FIELDS = List.of("model", "format", "keep_alive", "template"); + private static final List NON_SUPPORTED_FIELDS = List.of("model", "format", "keep_alive"); // @formatter:off /** @@ -255,13 +255,6 @@ public class OllamaOptions implements ChatOptions, EmbeddingOptions { */ @JsonProperty("keep_alive") private String keepAlive; - /** - * The prompt template to use (overrides what is defined in the Modelfile). - * Part of Chat completion advanced parameters. - */ - @JsonProperty("template") private String template; - - /** * @param model The ollama model names to use. See the {@link OllamaModel} for the common models. */ @@ -288,11 +281,6 @@ public OllamaOptions withKeepAlive(String keepAlive) { return this; } - public OllamaOptions withTemplate(String template) { - this.template = template; - return this; - } - public OllamaOptions withUseNUMA(Boolean useNUMA) { this.useNUMA = useNUMA; return this; @@ -469,14 +457,6 @@ public void setKeepAlive(String keepAlive) { this.keepAlive = keepAlive; } - public String getTemplate() { - return this.template; - } - - public void setTemplate(String template) { - this.template = template; - } - public Boolean getUseNUMA() { return this.useNUMA; } diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/ollama-chat.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/ollama-chat.adoc index cb83fd4ba3e..b46958e8977 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/ollama-chat.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/ollama-chat.adoc @@ -65,7 +65,6 @@ Here are the advanced request parameter for the Ollama chat client: | spring.ai.ollama.chat.options.model | The name of the https://github.com/ollama/ollama?tab=readme-ov-file#model-library[supported models] to use. | mistral | spring.ai.ollama.chat.options.format | The format to return a response in. Currently the only accepted value is `json` | - | spring.ai.ollama.chat.options.keep_alive | Controls how long the model will stay loaded into memory following the request | 5m -| spring.ai.ollama.chat.options.template | The prompt template to use (overrides what is defined in the Modelfile) | - |==== The `options` properties are based on the link:https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values[Ollama Valid Parameters and Values] and link:https://github.com/jmorganca/ollama/blob/main/api/types.go[Ollama Types]. The default values are based on: link:https://github.com/ollama/ollama/blob/b538dc3858014f94b099730a592751a5454cab0a/api/types.go#L364[Ollama type defaults].