Skip to content

Commit ea849d9

Browse files
ThomasVitaletzolov
authored andcommitted
Ollama: Remove unused option in chat completion
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
1 parent 7c09c09 commit ea849d9

File tree

4 files changed

+2
-35
lines changed

4 files changed

+2
-35
lines changed

models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/OllamaChatClient.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@ OllamaApi.ChatRequest ollamaChatRequest(Prompt prompt, boolean stream) {
174174
requestBuilder.withKeepAlive(mergedOptions.getKeepAlive());
175175
}
176176

177-
if (mergedOptions.getTemplate() != null) {
178-
requestBuilder.withTemplate(mergedOptions.getTemplate());
179-
}
180-
181177
return requestBuilder.build();
182178
}
183179

models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ public Message build() {
416416
* @param format The format to return the response in. Currently, the only accepted
417417
* value is "json".
418418
* @param keepAlive The duration to keep the model loaded in ollama while idle. https://pkg.go.dev/time#ParseDuration
419-
* @param template The prompt template (overrides what is defined in the Modelfile).
420419
* @param options Additional model parameters. You can use the {@link OllamaOptions} builder
421420
* to create the options then {@link OllamaOptions#toMap()} to convert the options into a
422421
* map.
@@ -428,7 +427,6 @@ public record ChatRequest(
428427
@JsonProperty("stream") Boolean stream,
429428
@JsonProperty("format") String format,
430429
@JsonProperty("keep_alive") String keepAlive,
431-
@JsonProperty("template") String template,
432430
@JsonProperty("options") Map<String, Object> options) {
433431

434432
public static Builder builder(String model) {
@@ -442,7 +440,6 @@ public static class Builder {
442440
private boolean stream = false;
443441
private String format;
444442
private String keepAlive;
445-
private String template;
446443
private Map<String, Object> options = Map.of();
447444

448445
public Builder(String model) {
@@ -470,11 +467,6 @@ public Builder withKeepAlive(String keepAlive) {
470467
return this;
471468
}
472469

473-
public Builder withTemplate(String template) {
474-
this.template = template;
475-
return this;
476-
}
477-
478470
public Builder withOptions(Map<String, Object> options) {
479471
Objects.requireNonNull(options, "The options can not be null.");
480472

@@ -489,7 +481,7 @@ public Builder withOptions(OllamaOptions options) {
489481
}
490482

491483
public ChatRequest build() {
492-
return new ChatRequest(model, messages, stream, format, keepAlive, template, options);
484+
return new ChatRequest(model, messages, stream, format, keepAlive, options);
493485
}
494486
}
495487
}

models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaOptions.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class OllamaOptions implements ChatOptions, EmbeddingOptions {
4545

4646
public static final String DEFAULT_MODEL = OllamaModel.MISTRAL.id();
4747

48-
private static final List<String> NON_SUPPORTED_FIELDS = List.of("model", "format", "keep_alive", "template");
48+
private static final List<String> NON_SUPPORTED_FIELDS = List.of("model", "format", "keep_alive");
4949

5050
// @formatter:off
5151
/**
@@ -255,13 +255,6 @@ public class OllamaOptions implements ChatOptions, EmbeddingOptions {
255255
*/
256256
@JsonProperty("keep_alive") private String keepAlive;
257257

258-
/**
259-
* The prompt template to use (overrides what is defined in the Modelfile).
260-
* Part of Chat completion <a href="https://github.com/ollama/ollama/blob/main/docs/api.md#parameters-1">advanced parameters</a>.
261-
*/
262-
@JsonProperty("template") private String template;
263-
264-
265258
/**
266259
* @param model The ollama model names to use. See the {@link OllamaModel} for the common models.
267260
*/
@@ -288,11 +281,6 @@ public OllamaOptions withKeepAlive(String keepAlive) {
288281
return this;
289282
}
290283

291-
public OllamaOptions withTemplate(String template) {
292-
this.template = template;
293-
return this;
294-
}
295-
296284
public OllamaOptions withUseNUMA(Boolean useNUMA) {
297285
this.useNUMA = useNUMA;
298286
return this;
@@ -469,14 +457,6 @@ public void setKeepAlive(String keepAlive) {
469457
this.keepAlive = keepAlive;
470458
}
471459

472-
public String getTemplate() {
473-
return this.template;
474-
}
475-
476-
public void setTemplate(String template) {
477-
this.template = template;
478-
}
479-
480460
public Boolean getUseNUMA() {
481461
return this.useNUMA;
482462
}

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/ollama-chat.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ Here are the advanced request parameter for the Ollama chat client:
6565
| 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
6666
| spring.ai.ollama.chat.options.format | The format to return a response in. Currently the only accepted value is `json` | -
6767
| spring.ai.ollama.chat.options.keep_alive | Controls how long the model will stay loaded into memory following the request | 5m
68-
| spring.ai.ollama.chat.options.template | The prompt template to use (overrides what is defined in the Modelfile) | -
6968
|====
7069

7170
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].

0 commit comments

Comments
 (0)