@@ -150,7 +150,9 @@ public record GenerateRequest(
150
150
@ JsonProperty ("template" ) String template ,
151
151
@ JsonProperty ("context" ) List <Integer > context ,
152
152
@ JsonProperty ("stream" ) Boolean stream ,
153
- @ JsonProperty ("raw" ) Boolean raw ) {
153
+ @ JsonProperty ("raw" ) Boolean raw ,
154
+ @ JsonProperty ("images" ) List <String > images ,
155
+ @ JsonProperty ("keep_alive" ) String keepAlive ) {
154
156
155
157
/**
156
158
* Short cut constructor to create a CompletionRequest without options.
@@ -159,7 +161,7 @@ public record GenerateRequest(
159
161
* @param stream Whether to stream the response.
160
162
*/
161
163
public GenerateRequest (String model , String prompt , Boolean stream ) {
162
- this (model , prompt , null , null , null , null , null , stream , null );
164
+ this (model , prompt , null , null , null , null , null , stream , null , null , null );
163
165
}
164
166
165
167
/**
@@ -170,7 +172,7 @@ public GenerateRequest(String model, String prompt, Boolean stream) {
170
172
* @param stream Whether to stream the response.
171
173
*/
172
174
public GenerateRequest (String model , String prompt , boolean enableJsonFormat , Boolean stream ) {
173
- this (model , prompt , (enableJsonFormat ) ? "json" : null , null , null , null , null , stream , null );
175
+ this (model , prompt , (enableJsonFormat ) ? "json" : null , null , null , null , null , stream , null , null , null );
174
176
}
175
177
176
178
/**
@@ -192,6 +194,8 @@ public static class Builder {
192
194
private List <Integer > context ;
193
195
private Boolean stream ;
194
196
private Boolean raw ;
197
+ private List <String > images ;
198
+ private String keepAlive ;
195
199
196
200
public Builder (String prompt ) {
197
201
this .prompt = prompt ;
@@ -242,8 +246,18 @@ public Builder withRaw(Boolean raw) {
242
246
return this ;
243
247
}
244
248
249
+ public Builder withImages (List <String > images ) {
250
+ this .images = images ;
251
+ return this ;
252
+ }
253
+
254
+ public Builder withKeepAlive (String keepAlive ) {
255
+ this .keepAlive = keepAlive ;
256
+ return this ;
257
+ }
258
+
245
259
public GenerateRequest build () {
246
- return new GenerateRequest (model , prompt , format , options , system , template , context , stream , raw );
260
+ return new GenerateRequest (model , prompt , format , options , system , template , context , stream , raw , images , keepAlive );
247
261
}
248
262
249
263
}
@@ -462,14 +476,14 @@ public Builder withTemplate(String template) {
462
476
}
463
477
464
478
public Builder withOptions (Map <String , Object > options ) {
465
- Objects .requireNonNullElse (options , "The options can not be null." );
479
+ Objects .requireNonNull (options , "The options can not be null." );
466
480
467
481
this .options = OllamaOptions .filterNonSupportedFields (options );
468
482
return this ;
469
483
}
470
484
471
485
public Builder withOptions (OllamaOptions options ) {
472
- Objects .requireNonNullElse (options , "The options can not be null." );
486
+ Objects .requireNonNull (options , "The options can not be null." );
473
487
this .options = OllamaOptions .filterNonSupportedFields (options .toMap ());
474
488
return this ;
475
489
}
@@ -574,6 +588,7 @@ public Flux<ChatResponse> streamingChat(ChatRequest chatRequest) {
574
588
public record EmbeddingRequest (
575
589
@ JsonProperty ("model" ) String model ,
576
590
@ JsonProperty ("prompt" ) String prompt ,
591
+ @ JsonProperty ("keep_alive" ) Duration keepAlive ,
577
592
@ JsonProperty ("options" ) Map <String , Object > options ) {
578
593
579
594
/**
@@ -582,7 +597,7 @@ public record EmbeddingRequest(
582
597
* @param prompt The text to generate embeddings for.
583
598
*/
584
599
public EmbeddingRequest (String model , String prompt ) {
585
- this (model , prompt , null );
600
+ this (model , prompt , null , null );
586
601
}
587
602
}
588
603
0 commit comments