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 API returns 500 with special characters #575

Open
johnnyheineken opened this issue Sep 27, 2024 · 4 comments
Open

Gemini API returns 500 with special characters #575

johnnyheineken opened this issue Sep 27, 2024 · 4 comments
Assignees
Labels
component:python sdk Issue/PR related to Python SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Something isn't working

Comments

@johnnyheineken
Copy link

johnnyheineken commented Sep 27, 2024

Description of the bug:

This exact code:

text = "čku“ s hodnotami ANO a NE 	+ „"
model = genai.GenerativeModel("gemini-1.5-flash")
result = model.generate_content(
    f"Can you summarize this text?\n{text}"
)
print(f"{result.text=}")

returns

InternalServerError: 500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting

Other malfunctioning strings:

'muláře \t- chybně vyplněný formulář \t- ji'

The problem seems to be with

U+0009 : <control> CHARACTER TABULATION [TAB] {horizontal tabulation (HT); tab}

Actual vs expected behavior:

Actual:
Returns 500

Expected:
Using Czech letters & Czech punctuation will not return 500 and the text will be summarised using Gemini, as requested

Any other information you'd like to share?

Windows 10,


sys.version_info(major=3, minor=9, micro=13, releaselevel='final', serial=0)
google-ai-generativelanguage             0.6.10
google-api-core                          2.17.1
google-api-python-client                 2.119.0
google-auth                              2.25.2
google-auth-httplib2                     0.2.0
google-cloud-aiplatform                  1.49.0
google-cloud-bigquery                    3.17.2
google-cloud-core                        2.4.1
google-cloud-resource-manager            1.12.2
google-cloud-storage                     2.14.0
google-crc32c                            1.5.0
google-generativeai                      0.8.2
google-resumable-media                   2.7.0
google-search-results                    2.4.2
googleapis-common-protos                 1.62.0
grpc-google-iam-v1                       0.13.0
langchain-google-genai                   0.0.6
@johnnyheineken johnnyheineken changed the title Gemini API returns 500 with special signs Gemini API returns 500 with special characters Sep 27, 2024
@Hamza-nabil
Copy link
Contributor

It does work with gemini-1.5-flash-002 the last stable version of Gemini 1.5 Flash (see Model versions and lifecycle).

code :

text = "čku“ s hodnotami ANO a NE 	+ „"
model = genai.GenerativeModel("gemini-1.5-flash-002")
result = model.generate_content(
    f"Can you summarize this text?\n{text}"
)
print(f"{result.text}")

Output :

The text "čku“ s hodnotami ANO a NE" translates from Czech to English as  "check" with values YES and NO.  It describes a binary check or a boolean variable.

@johnnyheineken
Copy link
Author

But the docs you sent are saying that I also should be using 002, according to this:

image

However I confirm that using "gemini-1.5-flash-002" works.

I also pinpointed the issue to U+0009 : <control> CHARACTER TABULATION [TAB] {horizontal tabulation (HT); tab}

@Hamza-nabil
Copy link
Contributor

What was the issue with U+0009 : <control> CHARACTER TABULATION [TAB] {horizontal tabulation (HT); tab} ?

@gmKeshari gmKeshari self-assigned this Sep 30, 2024
@gmKeshari gmKeshari added type:bug Something isn't working status:triaged Issue/PR triaged to the corresponding sub-team component:python sdk Issue/PR related to Python SDK labels Sep 30, 2024
@gmKeshari
Copy link

Hi @johnnyheineken . Sometimes we see Internal Server Error (500) because there are too many requests coming, which results in an unexpected error on Google's side. You can refer to this Troubleshooting doc "https://ai.google.dev/gemini-api/docs/troubleshooting?lang=python" I recommend temporarily switching to another model (e.g. from Gemini 1.5 Pro to Gemini 1.5 Flash) and see if it works Or wait a bit and retry your request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:python sdk Issue/PR related to Python SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants