Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VertexAI JsonDecodingException When requesting a Boolean parameter #6028

Closed
niqo01 opened this issue Jun 12, 2024 · 2 comments · Fixed by #6033
Closed

VertexAI JsonDecodingException When requesting a Boolean parameter #6028

niqo01 opened this issue Jun 12, 2024 · 2 comments · Fixed by #6033
Assignees

Comments

@niqo01
Copy link

niqo01 commented Jun 12, 2024

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Android Studio Koala | 2024.1.1 RC 2
  • Firebase Component: VertexAi
  • Component version: com.google.firebase:firebase-vertexai:16.0.0-beta01

[REQUIRED] Step 3: Describe the problem

I am declaring a function with Schema.bool("grewUpIn", "Whether the user grew up in this location or not."), and when Gemini call my function I get the following error:

com.google.firebase.vertexai.type.SerializationException: Something went wrong while trying to deserialize a response from the server.
17:17:45.834  I  	at com.google.firebase.vertexai.type.FirebaseVertexAIException$Companion.from(Exceptions.kt:41)
17:17:45.834  I  	at com.google.firebase.vertexai.GenerativeModel$generateContentStream$1.invokeSuspend(GenerativeModel.kt:147)
17:17:45.834  I  	at com.google.firebase.vertexai.GenerativeModel$generateContentStream$1.invoke(Unknown Source:9)
17:17:45.834  I  	at com.google.firebase.vertexai.GenerativeModel$generateContentStream$1.invoke(Unknown Source:6)
17:17:45.834  I  	at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:113)
17:17:45.834  I  	at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1$1.invokeSuspend(Unknown Source:15)
17:17:45.834  I  	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
17:17:45.834  I  	at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:28)
17:17:45.834  I  	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:99)
17:17:45.834  I  	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
17:17:45.835  I  	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
17:17:45.835  I  	at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
17:17:45.835  I  	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
17:17:45.835  I  	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
17:17:45.835  I  	at android.os.Handler.handleCallback(Handler.java:942)
17:17:45.835  I  	at android.os.Handler.dispatchMessage(Handler.java:99)
17:17:45.835  I  	at android.os.Looper.loopOnce(Looper.java:201)
17:17:45.835  I  	at android.os.Looper.loop(Looper.java:288)
17:17:45.835  I  	at android.app.ActivityThread.main(ActivityThread.java:7918)
17:17:45.835  I  	at java.lang.reflect.Method.invoke(Native Method)
17:17:45.835  I  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
17:17:45.835  I  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
17:17:45.835  I  Caused by: kotlinx.serialization.json.internal.JsonDecodingException: String literal for key 'grewUpIn' should be quoted at element: $.grewUpIn.
17:17:45.835  I  Use 'isLenient = true' in 'Json {}' builder to accept non-compliant JSON.
17:17:45.835  I  JSON input: {"yearsLived":"12","country":"US","grewUpIn":false,"region":""}
17:17:45.835  I  	at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
17:17:45.835  I  	at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
17:17:45.835  I  	at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeTaggedString(TreeJsonDecoder.kt:150)
17:17:45.835  I  	at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeTaggedString(TreeJsonDecoder.kt:37)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.decodeString(Tagged.kt:231)
17:17:45.835  I  	at kotlinx.serialization.internal.StringSerializer.deserialize(Primitives.kt:160)
17:17:45.835  I  	at kotlinx.serialization.internal.StringSerializer.deserialize(Primitives.kt:156)
17:17:45.835  I  	at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeSerializableValue(TreeJsonDecoder.kt:337)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.decodeSerializableValue(Tagged.kt:207)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.decodeSerializableElement$lambda$1(Tagged.kt:279)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.$r8$lambda$DBYIndnlKB76_oyt-Ap4f_T35nM(Unknown Source:0)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.tagBlock(Tagged.kt:294)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.decodeSerializableElement(Tagged.kt:279)
17:17:45.835  I  	at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:538)
17:17:45.835  I  	at kotlinx.serialization.internal.MapLikeSerializer.readElement(CollectionSerializers.kt:111)
17:17:45.835  I  	at kotlinx.serialization.internal.MapLikeSerializer.readElement(CollectionSerializers.kt:84)
17:17:45.835  I  	at kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)
17:17:45.835  I  	at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)
17:17:45.835  I  	at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
17:17:45.835  I  	at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeSerializableValue(TreeJsonDecoder.kt:337)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.decodeSerializableValue(Tagged.kt:207)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.decodeSerializableElement$lambda$1(Tagged.kt:279)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.$r8$lambda$DBYIndnlKB76_oyt-Ap4f_T35nM(Unknown Source:0)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.tagBlock(Tagged.kt:294)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.decodeSerializableElement(Tagged.kt:279)
17:17:45.835  I  	at com.google.ai.client.generativeai.common.shared.FunctionCall$$serializer.deserialize(Types.kt:62)
17:17:45.835  I  	at com.google.ai.client.generativeai.common.shared.FunctionCall$$serializer.deserialize(Types.kt:62)
17:17:45.835  I  	at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeSerializableValue(TreeJsonDecoder.kt:337)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.decodeSerializableValue(Tagged.kt:207)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.decodeSerializableElement$lambda$1(Tagged.kt:279)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.$r8$lambda$DBYIndnlKB76_oyt-Ap4f_T35nM(Unknown Source:0)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.tagBlock(Tagged.kt:294)
17:17:45.835  I  	at kotlinx.serialization.internal.TaggedDecoder.decodeSerializableElement(Tagged.kt:279)
17:17:45.835  I  	at com.google.ai.client.generativeai.common.shared.FunctionCallPart$$serializer.deserialize(Types.kt:56)
17:17:45.835  I  	at com.google.ai.client.generativeai.common.shared.FunctionCallPart$$serializer.deserialize(Types.kt:56)
17:17:45.835  I  	at kotlinx.serialization.json.internal.AbstractJsonTreeDecoder.decodeSerializableValue(TreeJsonDecoder.kt:337)
17:17:45.835  I  	at kotlinx.serialization.json.internal.TreeJsonDecoderKt.readJson(TreeJsonDecoder.kt:26)
17:17:45.835  I  	at kotlinx.serialization.json.Json.decodeFromJsonElement(Json.kt:186)
17:17:45.835  I  	at kotlinx.serialization.json.JsonContentPolymorphicSerializer.deserialize(JsonContentPolymorphicSerializer.kt:94)
17:17:45.835  I  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
17:17:45.835  I  	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
17:17:45.835  I  	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
17:17:45.835  I  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:168)
17:17:45.835  I  	at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:538)
17:17:45.835  I  	at kotlinx.serialization.internal.CollectionLikeSerializer.readElement(CollectionSerializers.kt:80)
17:17:45.835  I  	at kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)
17:17:45.835  I  	at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)
17:17:45.835  I  	at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
17:17:45.835  I  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
17:17:45.835  I  	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
17:17:45.835  I  	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
17:17:45.835  I  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:168)
17:17:45.835  I  	at com.google.ai.client.generativeai.common.shared.Content$$serializer.deserialize(Types.kt:46)
17:17:45.835  I  	at com.google.ai.client.generativeai.common.shared.Content$$serializer.deserialize(Types.kt:46)
17:17:45.835  I  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
17:17:45.836  I  	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
17:17:45.836  I  	at kotlinx.serialization.encoding.AbstractDecoder.decodeNullableSerializableElement(AbstractDecoder.kt:78)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.server.Candidate$$serializer.deserialize(Types.kt:51)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.server.Candidate$$serializer.deserialize(Types.kt:51)
17:17:45.836  I  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
17:17:45.836  I  	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
17:17:45.836  I  	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)
17:17:45.836  I  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:168)
17:17:45.836  I  	at kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:538)
17:17:45.836  I  	at kotlinx.serialization.internal.CollectionLikeSerializer.readElement(CollectionSerializers.kt:80)
17:17:45.836  I  	at kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)
17:17:45.836  I  	at kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)
17:17:45.836  I  	at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)
17:17:45.836  I  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
17:17:45.836  I  	at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)
17:17:45.836  I  	at kotlinx.serialization.encoding.AbstractDecoder.decodeNullableSerializableElement(AbstractDecoder.kt:78)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.GenerateContentResponse$$serializer.deserialize(Response.kt:26)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.GenerateContentResponse$$serializer.deserialize(Response.kt:26)
17:17:45.836  I  	at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
17:17:45.836  I  	at kotlinx.serialization.json.Json.decodeFromString(Json.kt:165)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1$1.invokeSuspend(ktor.kt:103)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1$1.invoke(Unknown Source:8)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1$1.invoke(Unknown Source:4)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.util.KtorKt.onEachLine(ktor.kt:52)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1.invokeSuspend(ktor.kt:82)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1.invoke(Unknown Source:8)
17:17:45.836  I  	at com.google.ai.client.generativeai.common.APIController$generateContentStream$$inlined$postStream$1$1$1$1.invoke(Unknown Source:4)
17:17:45.836  I  	at kotlinx.coroutines.flow.ChannelFlowBuilder.collectTo$suspendImpl(Builders.kt:316)
17:17:45.836  I  	at kotlinx.coroutines.flow.ChannelFlowBuilder.collectTo(Unknown Source:0)
17:17:45.836  I  	at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:56)
17:17:45.836  I  	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
17:17:45.836  I  	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
17:17:45.836  I  	... 11 more

It looks like the json is valid but the deserialization fails anyway.

Steps to reproduce:

  1. Call defineFunction with a boolean schema: Schema.bool("grewUpIn", "Whether the user grew up in this location or not.")
  2. Wait for the LLM to call the function and fails.
@google-oss-bot
Copy link
Contributor

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@daymxn
Copy link
Member

daymxn commented Jun 13, 2024

@niqo01 Thanks for the report! I've fixed this with #6033, and it should be live with the next release. The next release should be out by EOW next week (the 21st); baring any unforeseen circumstances. In the mean time, you can use a local artifact from the branch- which you can learn about here.

emilypgoogle pushed a commit that referenced this issue Jun 13, 2024
Per [b/346811894](https://b.corp.google.com/issues/346811894),

This fixes an issue with the VertexAI SDK failing to decode json
literals. More specifically, the fix was applied to
`generativeai:common` with `0.7.1`, and this PR bumps said dependency to
bring in the change.

Fixes #6028
@firebase firebase locked and limited conversation to collaborators Jul 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy