@@ -66,6 +66,9 @@ public static Builder builder() {
6666
6767 private static final Log logger = LogFactory .getLog (OllamaApi .class );
6868
69+
70+ private static final String DEFAULT_BASE_URL = "http://localhost:11434" ;
71+
6972 private final RestClient restClient ;
7073
7174 private final WebClient webClient ;
@@ -78,18 +81,22 @@ public static Builder builder() {
7881 * @param responseErrorHandler Response error handler.
7982 */
8083 private OllamaApi (String baseUrl , RestClient .Builder restClientBuilder , WebClient .Builder webClientBuilder , ResponseErrorHandler responseErrorHandler ) {
84+
85+
8186 Consumer <HttpHeaders > defaultHeaders = headers -> {
8287 headers .setContentType (MediaType .APPLICATION_JSON );
8388 headers .setAccept (List .of (MediaType .APPLICATION_JSON ));
8489 };
8590
91+
8692 this .restClient = restClientBuilder
8793 .clone ()
8894 .baseUrl (baseUrl )
8995 .defaultHeaders (defaultHeaders )
9096 .defaultStatusHandler (responseErrorHandler )
9197 .build ();
9298
99+
93100 this .webClient = webClientBuilder
94101 .clone ()
95102 .baseUrl (baseUrl )
@@ -252,22 +259,19 @@ public Flux<ProgressResponse> pullModel(PullModelRequest pullModelRequest) {
252259 *
253260 * @param role The role of the message of type {@link Role}.
254261 * @param content The content of the message.
262+ * @param thinking The thinking of the model.
255263 * @param images The list of base64-encoded images to send with the message.
256264 * Requires multimodal models such as llava or bakllava.
257- * @param toolCalls The list of tools that the model wants to use.
258- * @param toolName The name of the tool that was executed to inform the model of the result.
259- * @param thinking The model's thinking process. Requires thinking models such as qwen3.
265+ * @param toolCalls The relevant tool call.
260266 */
261267 @ JsonInclude (Include .NON_NULL )
262268 @ JsonIgnoreProperties (ignoreUnknown = true )
263269 public record Message (
264270 @ JsonProperty ("role" ) Role role ,
265271 @ JsonProperty ("content" ) String content ,
272+ @ JsonProperty ("thinking" ) String thinking ,
266273 @ JsonProperty ("images" ) List <String > images ,
267- @ JsonProperty ("tool_calls" ) List <ToolCall > toolCalls ,
268- @ JsonProperty ("tool_name" ) String toolName ,
269- @ JsonProperty ("thinking" ) String thinking
270- ) {
274+ @ JsonProperty ("tool_calls" ) List <ToolCall > toolCalls ) {
271275
272276 public static Builder builder (Role role ) {
273277 return new Builder (role );
@@ -316,29 +320,20 @@ public record ToolCall(
316320 *
317321 * @param name The name of the function.
318322 * @param arguments The arguments that the model expects you to pass to the function.
319- * @param index The index of the function call in the list of tool calls.
320323 */
321324 @ JsonInclude (Include .NON_NULL )
322325 public record ToolCallFunction (
323326 @ JsonProperty ("name" ) String name ,
324- @ JsonProperty ("arguments" ) Map <String , Object > arguments ,
325- @ JsonProperty ("index" ) Integer index
326- ) {
327-
328- public ToolCallFunction (String name , Map <String , Object > arguments ) {
329- this (name , arguments , null );
330- }
331-
327+ @ JsonProperty ("arguments" ) Map <String , Object > arguments ) {
332328 }
333329
334- public static final class Builder {
330+ public static class Builder {
335331
336332 private final Role role ;
337333 private String content ;
334+ private String thinking ;
338335 private List <String > images ;
339336 private List <ToolCall > toolCalls ;
340- private String toolName ;
341- private String thinking ;
342337
343338 public Builder (Role role ) {
344339 this .role = role ;
@@ -349,6 +344,11 @@ public Builder content(String content) {
349344 return this ;
350345 }
351346
347+ public Builder thinking (String thinking ) {
348+ this .thinking = thinking ;
349+ return this ;
350+ }
351+
352352 public Builder images (List <String > images ) {
353353 this .images = images ;
354354 return this ;
@@ -359,18 +359,8 @@ public Builder toolCalls(List<ToolCall> toolCalls) {
359359 return this ;
360360 }
361361
362- public Builder toolName (String toolName ) {
363- this .toolName = toolName ;
364- return this ;
365- }
366-
367- public Builder thinking (String thinking ) {
368- this .thinking = thinking ;
369- return this ;
370- }
371-
372362 public Message build () {
373- return new Message (this .role , this .content , this .images , this .toolCalls , this .toolName , this . thinking );
363+ return new Message (this .role , this .content , this .thinking , this .images , this .toolCalls );
374364 }
375365 }
376366 }
@@ -385,8 +375,8 @@ public Message build() {
385375 * @param keepAlive Controls how long the model will stay loaded into memory following this request (default: 5m).
386376 * @param tools List of tools the model has access to.
387377 * @param options Model-specific options. For example, "temperature" can be set through this field, if the model supports it.
388- * @param think Think controls whether thinking/reasoning models will think before responding.
389- * You can use the {@link OllamaChatOptions } builder to create the options then {@link OllamaChatOptions #toMap()} to convert the options into a map.
378+ * @param think The model should think before responding, if the model supports it .
379+ * You can use the {@link OllamaOptions } builder to create the options then {@link OllamaOptions #toMap()} to convert the options into a map.
390380 *
391381 * @see <a href=
392382 * "https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-chat-completion">Chat
@@ -467,7 +457,7 @@ public Function(String description, String name, String jsonSchema) {
467457 }
468458 }
469459
470- public static final class Builder {
460+ public static class Builder {
471461
472462 private final String model ;
473463 private List <Message > messages = List .of ();
@@ -515,21 +505,14 @@ public Builder options(Map<String, Object> options) {
515505 return this ;
516506 }
517507
518- public Builder think (Boolean think ) {
519- this .think = think ;
520- return this ;
521- }
522-
523- @ Deprecated
524508 public Builder options (OllamaOptions options ) {
525509 Objects .requireNonNull (options , "The options can not be null." );
526510 this .options = OllamaOptions .filterNonSupportedFields (options .toMap ());
527511 return this ;
528512 }
529513
530- public Builder options (OllamaChatOptions options ) {
531- Objects .requireNonNull (options , "The options can not be null." );
532- this .options = OllamaChatOptions .filterNonSupportedFields (options .toMap ());
514+ public Builder think (Boolean think ) {
515+ this .think = think ;
533516 return this ;
534517 }
535518
@@ -621,7 +604,7 @@ public Duration getEvalDuration() {
621604 public record EmbeddingsRequest (
622605 @ JsonProperty ("model" ) String model ,
623606 @ JsonProperty ("input" ) List <String > input ,
624- @ JsonProperty ("keep_alive" ) String keepAlive ,
607+ @ JsonProperty ("keep_alive" ) Duration keepAlive ,
625608 @ JsonProperty ("options" ) Map <String , Object > options ,
626609 @ JsonProperty ("truncate" ) Boolean truncate ) {
627610
@@ -751,7 +734,7 @@ public record ProgressResponse(
751734 @ JsonProperty ("completed" ) Long completed
752735 ) { }
753736
754- public static final class Builder {
737+ public static class Builder {
755738
756739 private String baseUrl = OllamaApiConstants .DEFAULT_BASE_URL ;
757740
0 commit comments