diff --git a/common/src/main/kotlin/com/google/ai/client/generativeai/common/client/Types.kt b/common/src/main/kotlin/com/google/ai/client/generativeai/common/client/Types.kt index 75c4b8f2..dd3cca42 100644 --- a/common/src/main/kotlin/com/google/ai/client/generativeai/common/client/Types.kt +++ b/common/src/main/kotlin/com/google/ai/client/generativeai/common/client/Types.kt @@ -39,7 +39,7 @@ data class Tool( val functionDeclarations: List? = null, // This is a json object because it is not possible to make a data class with no parameters. val codeExecution: JsonObject? = null, - val googleSearchRetrieval: GoogleSearchRetrieval? = null + val googleSearchRetrieval: GoogleSearchRetrieval? = null, ) @Serializable @@ -61,20 +61,14 @@ data class FunctionCallingConfig(val mode: Mode) { @Serializable data class FunctionDeclaration(val name: String, val description: String, val parameters: Schema) -@Serializable -data class GoogleSearchRetrieval(val dynamicRetrievalConfig: DynamicRetrievalConfig) +@Serializable data class GoogleSearchRetrieval(val dynamicRetrievalConfig: DynamicRetrievalConfig) @Serializable -data class DynamicRetrievalConfig( - val mode: Mode, - val dynamicThreshold: Float? -) { +data class DynamicRetrievalConfig(val mode: Mode, val dynamicThreshold: Float?) { @Serializable enum class Mode { - @SerialName("MODE_DYNAMIC") - DYNAMIC, - @SerialName("MODE_UNSPECIFIED") - UNSPECIFIED + @SerialName("MODE_DYNAMIC") DYNAMIC, + @SerialName("MODE_UNSPECIFIED") UNSPECIFIED } } diff --git a/generativeai/src/main/java/com/google/ai/client/generativeai/internal/util/conversions.kt b/generativeai/src/main/java/com/google/ai/client/generativeai/internal/util/conversions.kt index ca9603b7..59d57034 100644 --- a/generativeai/src/main/java/com/google/ai/client/generativeai/internal/util/conversions.kt +++ b/generativeai/src/main/java/com/google/ai/client/generativeai/internal/util/conversions.kt @@ -147,7 +147,7 @@ internal fun Tool.toInternal() = com.google.ai.client.generativeai.common.client.Tool( functionDeclarations?.map { it.toInternal() }, codeExecution = codeExecution?.toInternal(), - googleSearchRetrieval = googleSearchRetrieval?.toInternal() + googleSearchRetrieval = googleSearchRetrieval?.toInternal(), ) internal fun ToolConfig.toInternal() = @@ -193,17 +193,21 @@ internal fun com.google.ai.client.generativeai.type.Schema.toInternal(): internal fun JSONObject.toInternal() = Json.decodeFromString(toString()) -internal fun com.google.ai.client.generativeai.type.GoogleSearchRetrieval.toInternal(): GoogleSearchRetrieval { +internal fun com.google.ai.client.generativeai.type.GoogleSearchRetrieval.toInternal(): + GoogleSearchRetrieval { return GoogleSearchRetrieval(dynamicRetrievalConfig.toInternal()) } -internal fun com.google.ai.client.generativeai.type.DynamicRetrievalConfig.toInternal(): DynamicRetrievalConfig { +internal fun com.google.ai.client.generativeai.type.DynamicRetrievalConfig.toInternal(): + DynamicRetrievalConfig { return DynamicRetrievalConfig( when (mode) { - DynamicRetrievalMode.DYNAMIC -> com.google.ai.client.generativeai.common.client.DynamicRetrievalConfig.Mode.DYNAMIC - DynamicRetrievalMode.UNSPECIFIED -> com.google.ai.client.generativeai.common.client.DynamicRetrievalConfig.Mode.UNSPECIFIED + DynamicRetrievalMode.DYNAMIC -> + com.google.ai.client.generativeai.common.client.DynamicRetrievalConfig.Mode.DYNAMIC + DynamicRetrievalMode.UNSPECIFIED -> + com.google.ai.client.generativeai.common.client.DynamicRetrievalConfig.Mode.UNSPECIFIED }, - dynamicThreshold + dynamicThreshold, ) } diff --git a/generativeai/src/main/java/com/google/ai/client/generativeai/type/DynamicRetrievalConfig.kt b/generativeai/src/main/java/com/google/ai/client/generativeai/type/DynamicRetrievalConfig.kt index 1948d541..3931d18a 100644 --- a/generativeai/src/main/java/com/google/ai/client/generativeai/type/DynamicRetrievalConfig.kt +++ b/generativeai/src/main/java/com/google/ai/client/generativeai/type/DynamicRetrievalConfig.kt @@ -19,16 +19,15 @@ package com.google.ai.client.generativeai.type import androidx.annotation.FloatRange /* -* Specifies the dynamic retrieval configuration for the given source. -*/ + * Specifies the dynamic retrieval configuration for the given source. + */ data class DynamicRetrievalConfig( - /* - * The mode of the predictor to be used in dynamic retrieval. - */ - val mode: DynamicRetrievalMode, - /* - * (Optional) The threshold to be used in dynamic retrieval. If not set, a system default value is used. - */ - @FloatRange(0.0, 1.0) - val dynamicThreshold: Float? = null + /* + * The mode of the predictor to be used in dynamic retrieval. + */ + val mode: DynamicRetrievalMode, + /* + * (Optional) The threshold to be used in dynamic retrieval. If not set, a system default value is used. + */ + @FloatRange(0.0, 1.0) val dynamicThreshold: Float? = null, ) diff --git a/generativeai/src/main/java/com/google/ai/client/generativeai/type/DynamicRetrievalMode.kt b/generativeai/src/main/java/com/google/ai/client/generativeai/type/DynamicRetrievalMode.kt index 686b4de3..6c10865d 100644 --- a/generativeai/src/main/java/com/google/ai/client/generativeai/type/DynamicRetrievalMode.kt +++ b/generativeai/src/main/java/com/google/ai/client/generativeai/type/DynamicRetrievalMode.kt @@ -17,9 +17,9 @@ package com.google.ai.client.generativeai.type /* -* The mode of the predictor to be used in [DynamicRetrievalConfig]. -*/ + * The mode of the predictor to be used in [DynamicRetrievalConfig]. + */ enum class DynamicRetrievalMode { - DYNAMIC, - UNSPECIFIED + DYNAMIC, + UNSPECIFIED } diff --git a/generativeai/src/main/java/com/google/ai/client/generativeai/type/GoogleSearchRetrieval.kt b/generativeai/src/main/java/com/google/ai/client/generativeai/type/GoogleSearchRetrieval.kt index f4013067..7dcc0335 100644 --- a/generativeai/src/main/java/com/google/ai/client/generativeai/type/GoogleSearchRetrieval.kt +++ b/generativeai/src/main/java/com/google/ai/client/generativeai/type/GoogleSearchRetrieval.kt @@ -16,9 +16,5 @@ package com.google.ai.client.generativeai.type -/** - * Retrieval tool that is powered by Google search. - */ -data class GoogleSearchRetrieval( - val dynamicRetrievalConfig: DynamicRetrievalConfig -) +/** Retrieval tool that is powered by Google search. */ +data class GoogleSearchRetrieval(val dynamicRetrievalConfig: DynamicRetrievalConfig) diff --git a/generativeai/src/main/java/com/google/ai/client/generativeai/type/Tool.kt b/generativeai/src/main/java/com/google/ai/client/generativeai/type/Tool.kt index 6b0b4387..da85a0e6 100644 --- a/generativeai/src/main/java/com/google/ai/client/generativeai/type/Tool.kt +++ b/generativeai/src/main/java/com/google/ai/client/generativeai/type/Tool.kt @@ -31,7 +31,7 @@ class Tool constructor( val functionDeclarations: List? = null, val codeExecution: JSONObject? = null, - val googleSearchRetrieval: GoogleSearchRetrieval? = null + val googleSearchRetrieval: GoogleSearchRetrieval? = null, ) { companion object { @JvmField val CODE_EXECUTION = Tool(codeExecution = JSONObject())