Package com.google.adk.models.springai
Class ConfigMapper
java.lang.Object
com.google.adk.models.springai.ConfigMapper
Maps between ADK
GenerateContentConfig and Spring AI ChatOptions in both
directions.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.ai.chat.prompt.ChatOptionsCreates default ChatOptions for cases where no ADK config is provided.booleanisChatOptionsValid(@Nullable org.springframework.ai.chat.prompt.ChatOptions chatOptions) Validates that Spring AIChatOptionsvalues fall within valid ADK generation bounds.booleanisConfigurationValid(Optional<com.google.genai.types.GenerateContentConfig> config) Validates that the configuration is compatible with Spring AI.@Nullable com.google.genai.types.GenerateContentConfigtoGenerateContentConfig(@Nullable org.springframework.ai.chat.prompt.ChatOptions chatOptions) Converts Spring AIChatOptionsto an ADKGenerateContentConfig.@Nullable org.springframework.ai.chat.prompt.ChatOptionstoSpringAiChatOptions(Optional<com.google.genai.types.GenerateContentConfig> config) Converts ADK GenerateContentConfig to Spring AI ChatOptions.
-
Constructor Details
-
ConfigMapper
public ConfigMapper()
-
-
Method Details
-
toSpringAiChatOptions
public @Nullable org.springframework.ai.chat.prompt.ChatOptions toSpringAiChatOptions(Optional<com.google.genai.types.GenerateContentConfig> config) Converts ADK GenerateContentConfig to Spring AI ChatOptions.When
GenerateContentConfig.responseJsonSchema()orGenerateContentConfig.responseSchema()is present, the returned options implementStructuredOutputChatOptionscarrying the serialized JSON schema.- Parameters:
config- The ADK configuration to convert- Returns:
- Spring AI ChatOptions or null if no config provided
-
toGenerateContentConfig
public @Nullable com.google.genai.types.GenerateContentConfig toGenerateContentConfig(@Nullable org.springframework.ai.chat.prompt.ChatOptions chatOptions) Converts Spring AIChatOptionsto an ADKGenerateContentConfig.When
chatOptionsimplementsStructuredOutputChatOptionswith a non-blank output schema, the parsed schema is set asGenerateContentConfig.responseJsonSchema()with a JSON response MIME type.- Parameters:
chatOptions- The Spring AI chat options to convert, or null- Returns:
- ADK
GenerateContentConfig, or null ifchatOptionsis null
-
createDefaultChatOptions
public org.springframework.ai.chat.prompt.ChatOptions createDefaultChatOptions()Creates default ChatOptions for cases where no ADK config is provided.- Returns:
- Basic ChatOptions with reasonable defaults
-
isConfigurationValid
Validates that the configuration is compatible with Spring AI.- Parameters:
config- The ADK configuration to validate- Returns:
- true if configuration is valid and supported
-
isChatOptionsValid
public boolean isChatOptionsValid(@Nullable org.springframework.ai.chat.prompt.ChatOptions chatOptions) Validates that Spring AIChatOptionsvalues fall within valid ADK generation bounds.- Parameters:
chatOptions- The Spring AI chat options to validate, or null- Returns:
- true if the options are valid
-