Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/main/java/com/google/genai/interactions/core/Check.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,4 @@ private val RUNTIME_JACKSON_VERSIONS: List<Version> =
com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION,
com.fasterxml.jackson.datatype.jdk8.PackageVersion.VERSION,
com.fasterxml.jackson.datatype.jsr310.PackageVersion.VERSION,
com.fasterxml.jackson.module.kotlin.PackageVersion.VERSION,
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.databind.type.LogicalType
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.kotlinModule
import java.io.InputStream
import java.time.DateTimeException
import java.time.LocalDate
Expand All @@ -47,7 +46,6 @@ import java.time.temporal.ChronoField

fun jsonMapper(): JsonMapper =
JsonMapper.builder()
.addModule(kotlinModule())
.addModule(Jdk8Module())
.addModule(JavaTimeModule())
.addModule(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package com.google.genai.interactions.core.handlers

import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.fasterxml.jackson.core.type.TypeReference
import com.google.genai.interactions.core.http.HttpResponse
import com.google.genai.interactions.core.http.HttpResponse.Handler
import com.google.genai.interactions.errors.GeminiNextGenApiInvalidDataException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package com.google.genai.interactions.core.http

import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.fasterxml.jackson.core.type.TypeReference
import com.google.genai.interactions.errors.GeminiNextGenApiInvalidDataException
import java.util.Objects

Expand Down Expand Up @@ -59,7 +59,7 @@ private constructor(

inline fun <reified T> json(): T =
try {
jsonMapper.readerFor(jacksonTypeRef<T>()).readValue(jsonNode)
jsonMapper.readerFor(object : TypeReference<T>() {}).readValue(jsonNode)
} catch (e: Exception) {
throw GeminiNextGenApiInvalidDataException("Error reading response", e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.fasterxml.jackson.core.type.TypeReference
import com.google.genai.interactions.core.BaseDeserializer
import com.google.genai.interactions.core.BaseSerializer
import com.google.genai.interactions.core.JsonValue
Expand Down Expand Up @@ -204,17 +204,17 @@ private constructor(

when (type) {
"url_citation" -> {
return tryDeserialize(node, jacksonTypeRef<UrlCitation>())?.let {
return tryDeserialize(node, object : TypeReference<UrlCitation>() {})?.let {
Annotation(urlCitation = it, _json = json)
} ?: Annotation(_json = json)
}
"file_citation" -> {
return tryDeserialize(node, jacksonTypeRef<FileCitation>())?.let {
return tryDeserialize(node, object : TypeReference<FileCitation>() {})?.let {
Annotation(fileCitation = it, _json = json)
} ?: Annotation(_json = json)
}
"place_citation" -> {
return tryDeserialize(node, jacksonTypeRef<PlaceCitation>())?.let {
return tryDeserialize(node, object : TypeReference<PlaceCitation>() {})?.let {
Annotation(placeCitation = it, _json = json)
} ?: Annotation(_json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.fasterxml.jackson.core.type.TypeReference
import com.google.genai.interactions.core.BaseDeserializer
import com.google.genai.interactions.core.BaseSerializer
import com.google.genai.interactions.core.JsonValue
Expand Down Expand Up @@ -247,27 +247,27 @@ private constructor(

when (type) {
"text" -> {
return tryDeserialize(node, jacksonTypeRef<TextContent>())?.let {
return tryDeserialize(node, object : TypeReference<TextContent>() {})?.let {
Content(text = it, _json = json)
} ?: Content(_json = json)
}
"image" -> {
return tryDeserialize(node, jacksonTypeRef<ImageContent>())?.let {
return tryDeserialize(node, object : TypeReference<ImageContent>() {})?.let {
Content(image = it, _json = json)
} ?: Content(_json = json)
}
"audio" -> {
return tryDeserialize(node, jacksonTypeRef<AudioContent>())?.let {
return tryDeserialize(node, object : TypeReference<AudioContent>() {})?.let {
Content(audio = it, _json = json)
} ?: Content(_json = json)
}
"document" -> {
return tryDeserialize(node, jacksonTypeRef<DocumentContent>())?.let {
return tryDeserialize(node, object : TypeReference<DocumentContent>() {})?.let {
Content(document = it, _json = json)
} ?: Content(_json = json)
}
"video" -> {
return tryDeserialize(node, jacksonTypeRef<VideoContent>())?.let {
return tryDeserialize(node, object : TypeReference<VideoContent>() {})?.let {
Content(video = it, _json = json)
} ?: Content(_json = json)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.fasterxml.jackson.core.type.TypeReference
import com.google.genai.interactions.core.BaseDeserializer
import com.google.genai.interactions.core.BaseSerializer
import com.google.genai.interactions.core.Enum
Expand Down Expand Up @@ -1635,28 +1635,28 @@ private constructor(

val bestMatches =
sequenceOf(
tryDeserialize(node, jacksonTypeRef<TextContent>())?.let {
tryDeserialize(node, object : TypeReference<TextContent>() {})?.let {
Input(textContent = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<ImageContent>())?.let {
tryDeserialize(node, object : TypeReference<ImageContent>() {})?.let {
Input(imageContent = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<AudioContent>())?.let {
tryDeserialize(node, object : TypeReference<AudioContent>() {})?.let {
Input(audioContent = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<DocumentContent>())?.let {
tryDeserialize(node, object : TypeReference<DocumentContent>() {})?.let {
Input(documentContent = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<VideoContent>())?.let {
tryDeserialize(node, object : TypeReference<VideoContent>() {})?.let {
Input(videoContent = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<String>())?.let {
tryDeserialize(node, object : TypeReference<String>() {})?.let {
Input(string = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<List<Step>>())?.let {
tryDeserialize(node, object : TypeReference<List<Step>>() {})?.let {
Input(stepList = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<List<Content>>())?.let {
tryDeserialize(node, object : TypeReference<List<Content>>() {})?.let {
Input(contentList = it, _json = json)
},
)
Expand Down Expand Up @@ -1848,12 +1848,12 @@ private constructor(

when (type) {
"dynamic" -> {
return tryDeserialize(node, jacksonTypeRef<DynamicAgentConfig>())?.let {
return tryDeserialize(node, object : TypeReference<DynamicAgentConfig>() {})?.let {
AgentConfig(dynamic = it, _json = json)
} ?: AgentConfig(_json = json)
}
"deep-research" -> {
return tryDeserialize(node, jacksonTypeRef<DeepResearchAgentConfig>())
return tryDeserialize(node, object : TypeReference<DeepResearchAgentConfig>() {})
?.let { AgentConfig(deepResearch = it, _json = json) }
?: AgentConfig(_json = json)
}
Expand Down Expand Up @@ -2116,22 +2116,22 @@ private constructor(

val bestMatches =
sequenceOf(
tryDeserialize(node, jacksonTypeRef<AudioResponseFormat>())?.let {
tryDeserialize(node, object : TypeReference<AudioResponseFormat>() {})?.let {
ResponseFormat(audio = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<TextResponseFormat>())?.let {
tryDeserialize(node, object : TypeReference<TextResponseFormat>() {})?.let {
ResponseFormat(text = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<ImageResponseFormat>())?.let {
tryDeserialize(node, object : TypeReference<ImageResponseFormat>() {})?.let {
ResponseFormat(image = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<VideoResponseFormat>())?.let {
tryDeserialize(node, object : TypeReference<VideoResponseFormat>() {})?.let {
ResponseFormat(video = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<List<InnerResponseFormat>>())?.let {
tryDeserialize(node, object : TypeReference<List<InnerResponseFormat>>() {})?.let {
ResponseFormat(list = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let {
tryDeserialize(node, object : TypeReference<JsonValue>() {})?.let {
ResponseFormat(jsonValue = it, _json = json)
},
)
Expand Down Expand Up @@ -2387,19 +2387,19 @@ private constructor(

val bestMatches =
sequenceOf(
tryDeserialize(node, jacksonTypeRef<AudioResponseFormat>())?.let {
tryDeserialize(node, object : TypeReference<AudioResponseFormat>() {})?.let {
InnerResponseFormat(audio = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<TextResponseFormat>())?.let {
tryDeserialize(node, object : TypeReference<TextResponseFormat>() {})?.let {
InnerResponseFormat(text = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<ImageResponseFormat>())?.let {
tryDeserialize(node, object : TypeReference<ImageResponseFormat>() {})?.let {
InnerResponseFormat(image = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<VideoResponseFormat>())?.let {
tryDeserialize(node, object : TypeReference<VideoResponseFormat>() {})?.let {
InnerResponseFormat(video = it, _json = json)
},
tryDeserialize(node, jacksonTypeRef<JsonValue>())?.let {
tryDeserialize(node, object : TypeReference<JsonValue>() {})?.let {
InnerResponseFormat(jsonValue = it, _json = json)
},
)
Expand Down
Loading
Loading