firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.25k stars 572 forks source link

VertexAI ServerException when sending a message with a Function response part using sendMessageStream #6042

Closed niqo01 closed 2 months ago

niqo01 commented 3 months ago

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

When sending a function response part using sendMessageStream I receive the following error:

ServerException: Unable to submit request because it must include at least one parts field, which describes the prompt input. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini (Ask Gemini)
                    at com.google.firebase.vertexai.type.FirebaseVertexAIException$Companion.from(Exceptions.kt:43)
                    at com.google.firebase.vertexai.GenerativeModel$generateContentStream$1.invokeSuspend(GenerativeModel.kt:147)
                    at com.google.firebase.vertexai.GenerativeModel$generateContentStream$1.invoke(Unknown Source:9)
                    at com.google.firebase.vertexai.GenerativeModel$generateContentStream$1.invoke(Unknown Source:6)
                    at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:113)
                    at kotlinx.coroutines.flow.FlowKt__ErrorsKt$catch$$inlined$unsafeFlow$1$1.invokeSuspend(Unknown Source:15)
                    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)

The Firebase documentation sample here does not add a part field describing the prompt in case of a function response.

Steps to reproduce:

Call sendMessageStream with a Content Part as follow:

Screenshot 2024-06-17 at 21 26 23
google-oss-bot commented 3 months ago

I found a few problems with this issue:

rlazo commented 3 months ago

Hey @niqo01 thanks a lot for your report. This issue should be fixed by https://github.com/firebase/firebase-android-sdk/pull/6033

I'll keep this issue opened until we released a new version containing the fix so you can track it.

rlazo commented 2 months ago

Hey @niqo01 give beta03 version a try, it should address your issue

https://maven.google.com/web/index.html?q=vertex#com.google.firebase:firebase-vertexai:16.0.0-beta03

Thanks!