Skip to content

Internal Error 500 when using function calls and multimodal prompts together #396

@soundkprz

Description

@soundkprz

Description of the bug:

When sending a multimodal request to the model via the Python SDK while also defining tools / function declarations I consistently receive an internal error 500. If I take away the tools OR the image and keep the other it works again.
I haven't changed anything about the code and it has worked before just fine, but now I suddenly get this error.

Actual vs expected behavior:

Actual: I receive an error 500

Expected: The modal should handle the request and respond without error

Any other information you'd like to share?

google_search_query = FunctionDeclaration(
name="search_and_scrape",
description="Get results from a Google Search",
parameters={
"type": "object",
"properties": {
"query": {"type": "string", "description": "Search query"}
},
},
)

search_tools = Tool(
function_declarations=[google_search_query]
)

model = GenerativeModel(
"gemini-1.5-pro-preview-0409",
generation_config=GenerationConfig(
temperature=0.6,
max_output_tokens=2048
),
tools=[search_tools])

async def main():
# User prompt
prompt = "What are the latest news for Paris?"
image_url = [image]
loaded_image = [load_image_from_url(url) for url in image_url]
print("In the function now")

response = model.generate_content(list(loaded_image) + [prompt], tools=[search_tools])
print(response)
  File "C:\Users\djhar\PycharmProjects\Discord Bot with PaLM\venv\Lib\site-packages\google\api_core\grpc_helpers.py", line 76, in error_remapped_callable
    return callable_(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\djhar\PycharmProjects\Discord Bot with PaLM\venv\Lib\site-packages\grpc\_channel.py", line 1181, in __call__
    return _end_unary_response_blocking(state, call, False, None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\djhar\PycharmProjects\Discord Bot with PaLM\venv\Lib\site-packages\grpc\_channel.py", line 1006, 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 = "Internal error encountered."
    debug_error_string = "UNKNOWN:Error received from peer ipv4:142.250.185.170:443 {created_time:"2024-05-01T11:47:48.4953737+00:00", grpc_status:13, grpc_message:"Internal error encountered."}"```

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions