Class AdvisorParams

java.lang.Object
org.springframework.ai.chat.client.AdvisorParams

public final class AdvisorParams extends Object
Configuration options for the ChatClient request. Preset advisors parameters that can be passed as configuration options to the Advisor context.
Author:
Christian Tzolov
  • Field Details

    • ENABLE_NATIVE_STRUCTURED_OUTPUT

      public static final Consumer<ChatClient.AdvisorSpec> ENABLE_NATIVE_STRUCTURED_OUTPUT
      Advisor parameter that enables provider-native structured output for all entity() calls on a prompt. When set, the JSON schema is delivered to the AI provider as an API-level constraint rather than appended as prompt text.

      Not enabled by default because native structured output support varies across models and providers. Known limitations:

      • Ollama: models with a built-in reasoning/thinking mode (e.g. qwen3:8b, qwen3.5:9b) may return plain text instead of JSON, causing deserialization failures.
      • OpenAI: the Structured Outputs API does not accept a top-level JSON array schema. Requesting a List<T> will fail; wrap the list in a container record or use the default prompt-based approach instead.

      For per-call control prefer ChatClient.EntityParamSpec.useProviderStructuredOutput().

  • Method Details

    • toolCallingAdvisorAutoRegister

      public static Consumer<ChatClient.AdvisorSpec> toolCallingAdvisorAutoRegister(boolean enabled)
      Controls whether a ToolCallingAdvisor is automatically added to the chain. Auto-registration is enabled by default so that tools injected at runtime by another advisor are handled correctly even when no static tools are configured. No explicit ToolAdvisor must be present. Pass false to opt out:
      
       client.prompt()
           .tools(myTool)
           .advisors(AdvisorParams.toolCallingAdvisorAutoRegister(false))
           .call();
       
    • toolCallAdvisorAutoRegister

      @Deprecated(since="2.0.0", forRemoval=true) public static Consumer<ChatClient.AdvisorSpec> toolCallAdvisorAutoRegister(boolean enabled)
      Deprecated, for removal: This API element is subject to removal in a future version.