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

Gemini 1.5 Pro Error: "Something went wrong while trying to deserialize a response from the server." #160

Closed
karloti opened this issue May 30, 2024 · 15 comments
Assignees
Labels
component:android sdk Issue/PR related to Android SDK status:awaiting user response Awaiting a response from the author type:bug Something isn't working

Comments

@karloti
Copy link

karloti commented May 30, 2024

Description of the bug:

I get this error very, very often. I wait about 15 seconds and repeat the prompt until I get a normal response. The prompt is not in English. This wastes a lot of time and I don't know how to fix it. Is there a way to handle errors? The model returns them to normal text that I have to parse. So far I have received over x3 types of different errors from Gemini 1.5 Pro.

image

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

@karloti
Copy link
Author

karloti commented May 30, 2024

BILLING from google.ai.generativelanguage.v1beta.GenerativeService.GenerateContent

Gemini requests are currently being billed to me. The problem is that I get an error from the library and no result.
Please tell me what to do? This library has a serialization error. I repeatedly repeat the request until I get an answer that does not have an error and in this way insanely large amounts are charged. Is there a way to not charge these errors? If not, in this case this library is not appropriate to use because it generates billing that is without any content.
For example, here is the following error:

image

dump.txt

@rlazo
Copy link
Collaborator

rlazo commented May 30, 2024

Hey @karloti could you share the prompt you are using that's triggering the deserialization issue for debugging?

@karloti
Copy link
Author

karloti commented May 30, 2024

Hello,
thanks for your quick reply.
I think this is where the problem comes from. I'm thinking of replacing it with a String scheme

image

@davidmotson
Copy link
Collaborator

I think the issue may be because you are subclassing FunctionDeclaration. This is not the intended use. Does this error also occur if you use the defineFunction methods?

@rlazo
Copy link
Collaborator

rlazo commented May 30, 2024

Sounds like a possibility, since the trace points to that line

	at com.google.ai.client.generativeai.common.shared.FunctionCall$$serializer.deserialize(Types.kt:62)

that being said, it should absolutely not fail deserializing. The model is not returning a value that we were expecting.

@davidmotson
Copy link
Collaborator

relatedly, if you happen to be able to pull the text of one of these responses that fails to parse that would help debugging immensely. If you're in android studio you can use the network inspector in App Inspection to accomplish this.

@karloti
Copy link
Author

karloti commented May 30, 2024

I made a change to the code but it didn't help. It keeps giving the same error. After a few tries it manages to return a correct result, but this is not a good idea because it is charged.

image
image

@karloti
Copy link
Author

karloti commented May 30, 2024

relatedly, if you happen to be able to pull the text of one of these responses that fails to parse that would help debugging immensely. If you're in android studio you can use the network inspector in App Inspection to accomplish this.

I can give you the prompt, but I don't want it here publicly. Maybe an email. Note that the prompt is in Bulgarian and this may be a problem. However, the fact is that the same prompt has no problem in AI Studio

@davidmotson
Copy link
Collaborator

Actually, the response is more important, Feel free to remove any strings you like from it, the structure is whats important.

If you'd prefer to email it to me, you can email it to davidmotson@google.com

@rlazo
Copy link
Collaborator

rlazo commented May 30, 2024

Alternatively, you could record request/responses send to the server using https://developer.android.com/studio/debug/network-profiler

That would allow us to see what gets send and what you get back. As @davidmotson said, structure matters rather than content, so you can edit out the values.

@karloti
Copy link
Author

karloti commented May 31, 2024

I forked generative-ai-android.git
I suspect that the error is caused by the serialization of the returned list of candidates.

image
image

@karloti
Copy link
Author

karloti commented May 31, 2024

Alternatively, you could record request/responses send to the server using https://developer.android.com/studio/debug/network-profiler

That would allow us to see what gets send and what you get back. As @davidmotson said, structure matters rather than content, so you can edit out the values.

Temporarily stopped the Gemini API

I've also temporarily stopped the Gemini API for obvious reasons and can't give you a result from Network Inspector, but I've emailed everything I need and described the problem pretty well.

I hope you fix the error as soon as possible!

I have used type safe text for TextPart(val text: String)

I have no null strings passed
I also emailed the prompt to @davidmotson which shows that everything is normal.
here is the code snippet which appears to be null safe (prompt):

image

@karloti
Copy link
Author

karloti commented Jun 5, 2024

This bug will be fixed in v0.8.0
I have already tested the latest update and the bug is caught.
Thanks to David for fixing this.

@karloti karloti closed this as completed Jun 5, 2024
@karloti
Copy link
Author

karloti commented Jun 8, 2024

@karloti karloti reopened this Jun 8, 2024
@rlazo rlazo assigned davidmotson and unassigned rlazo Jun 10, 2024
@rlazo
Copy link
Collaborator

rlazo commented Jun 12, 2024

image image image image

@davidmotson https://drive.google.com/drive/folders/10S8eA3nXlkxUjqlK9EuIptzDMF7WQJf1?usp=sharing

Seems like this is not the same issue as the original one. Please create a new issue to track it separately. Thanks!

New version 0.8.0 has been published, including the fix to the original issue.

@rlazo rlazo closed this as completed Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:android sdk Issue/PR related to Android SDK status:awaiting user response Awaiting a response from the author type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants