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

google.api_core.exceptions.InternalServerError: 500 An internal error has occurred. #122

Closed
JoshuaEworo opened this issue Dec 15, 2023 · 5 comments
Labels
component:python sdk Issue/PR related to Python SDK type:bug Something isn't working

Comments

@JoshuaEworo
Copy link

JoshuaEworo commented Dec 15, 2023

Description of the bug:

The error occurs when "res = geminiClient.generate_content(conversation).text" is reached again in a recursive function call.
I expected it to work the same way it did over the function's first pass. How do i fix this?

Error/Bug Found:

Traceback (most recent call last):
  File "C:\Users\eworo\DELTA\env\Lib\site-packages\google\api_core\grpc_helpers.py", line 79, in error_remapped_callable
    return callable_(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eworo\DELTA\env\Lib\site-packages\grpc\_channel.py", line 1160, in __call__
    return _end_unary_response_blocking(state, call, False, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eworo\DELTA\env\Lib\site-packages\grpc\_channel.py", line 1003, in _end_unary_response_blocking
    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INTERNAL
        details = "An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting"
        debug_error_string = "UNKNOWN:Error received from peer ipv4:142.250.115.95:443 {created_time:"2023-12-15T04:18:34.1915935+00:00", grpc_status:13, grpc_message:"An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting"}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\Users\eworo\DELTA\src\test.py", line 48, in <module>
    infer(input("Q: "))
  File "c:\Users\eworo\DELTA\src\test.py", line 45, in infer
    infer("")
  File "c:\Users\eworo\DELTA\src\test.py", line 40, in infer
    res = geminiClient.generate_content(conversation).text
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eworo\DELTA\env\Lib\site-packages\google\generativeai\generative_models.py", line 243, in generate_content
    response = self._client.generate_content(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eworo\DELTA\env\Lib\site-packages\google\ai\generativelanguage_v1beta\services\generative_service\client.py", line 566, in generate_content
    response = rpc(
               ^^^^
  File "C:\Users\eworo\DELTA\env\Lib\site-packages\google\api_core\gapic_v1\method.py", line 131, in __call__
    return wrapped_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eworo\DELTA\env\Lib\site-packages\google\api_core\retry.py", line 372, in retry_wrapped_func
    return retry_target(
           ^^^^^^^^^^^^^
  File "C:\Users\eworo\DELTA\env\Lib\site-packages\google\api_core\retry.py", line 207, in retry_target
    result = target()
             ^^^^^^^^
  File "C:\Users\eworo\DELTA\env\Lib\site-packages\google\api_core\timeout.py", line 120, in func_with_timeout
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eworo\DELTA\env\Lib\site-packages\google\api_core\grpc_helpers.py", line 81, in error_remapped_callable
    raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.InternalServerError: 500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting

Any other information you'd like to share?

I was using the Gemini API.

Here is code to recreate the error:

import google.generativeai as genai

genai.configure(api_key="API_KEY")

geminiClient = genai.GenerativeModel(model_name="gemini-pro")

conversation = [{'role':'user','parts': [f"Hello!"]}, {'role':'model','parts': ["Hey there Anon!"]}]


def infer(query):
    conversation.append({'role':'user','parts': [query]})
    res = geminiClient.generate_content(conversation).text
    print("A: " + res)
    conversation.append({'role':'model','parts': [res]})

    if res == "Y":
        infer("")

while True:
    infer(input("Q: "))

To attain the error, tell the model "only respond to me with "Y" until i say stop".

@JoshuaEworo JoshuaEworo added component:python sdk Issue/PR related to Python SDK type:bug Something isn't working labels Dec 15, 2023
@JoshuaEworo
Copy link
Author

JoshuaEworo commented Dec 15, 2023

UPDATE (Problem resolved): Turns out this happens if an empty string is passed as a part.

@saikatmitra91
Copy link

saikatmitra91 commented Jan 10, 2024

the issue is still valid I believe. We should fix the status code of 500.

@suqi
Copy link

suqi commented Mar 12, 2024

Still 500 everyday.
I would suggest team to check the backend 500 logs, and fix one by one. 😄

@LindaLawton
Copy link

LindaLawton commented Mar 15, 2024

This is a known issue with the model and not related to the library see #236 236

@MarkDaoust
Copy link
Collaborator

We've had a few patches of intermittent 500 errors in the past. I think this is fixed. But please reopen if yiou find that it's still reproducible.

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 type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants