firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

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

Open niqo01 opened this issue 1 year ago • 2 comments

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Android Studio Koala | 2024.1.1
  • Firebase Component: VertexAI
  • Component version: 16.0.0-beta01

[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

niqo01 avatar Jun 17 '24 19:06 niqo01

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.

google-oss-bot avatar Jun 17 '24 19:06 google-oss-bot

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 avatar Jun 18 '24 16:06 rlazo

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!

rlazo avatar Jul 17 '24 18:07 rlazo