I've recently run across a strange issue when using the Gemini Pro Vision API. I've been running the same prompt testing a new system for the last week or so. Most of the time, everything works as expected, but on occasion, I get back this exception:
`google.api_core.exceptions.InvalidArgument: 400 Request contains an invalid argument.`
The only way to reproduce this result is by re-running my script enough times until I get the error again. Like I said, the prompt is the same each time. Here's the full stack trace:
```
Traceback (most recent call last):
response = self.model.generate_content( File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py", line 353, in generate_content return self._generate_content( File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py", line 437, in _generate_content stream = self._prediction_client.stream_generate_content(request=request) File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py", line 1634, in stream_generate_content response = rpc( File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__ return wrapped_func(*args, **kwargs) File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 169, in error_remapped_callable raise exceptions.from_grpc_error(exc) from exc google.api_core.exceptions.InvalidArgument: 400 Request contains an invalid argument. Traceback (most recent call last): File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 165, in error_remapped_callable return _StreamingResponseIterator( File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 91, in __init__ self._stored_first_result = next(self._wrapped) File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/grpc/_channel.py", line 540, in __next__ return self._next() File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/grpc/_channel.py", line 966, in _next raise self grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with: status = StatusCode.INVALID_ARGUMENT details = "Request contains an invalid argument." debug_error_string = "UNKNOWN:Error received from peer ipv4:172.217.0.74:443 {grpc_message:"Request contains an invalid argument.", grpc_status:3, created_time:"2024-01-22T16:19:31.40909-07:00"}" > The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/spenceryoung/Desktop/DAI/code/cybernetics/cybernetics/vision/pricing/price_extractor.py", line 91, in _extract_keyframe_prices response = self.model.generate_content( File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py", line 353, in generate_content return self._generate_content( File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py", line 437, in _generate_content stream = self._prediction_client.stream_generate_content(request=request) File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py", line 1634, in stream_generate_content response = rpc( File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__ return wrapped_func(*args, **kwargs) File "/Users/spenceryoung/miniconda3/envs/cybernetics/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 169, in error_remapped_callable raise exceptions.from_grpc_error(exc) from exc google.api_core.exceptions.InvalidArgument: 400 Request contains an invalid argument.
```
One thing to note is that I'm calling the API from a multi-threaded environment (to make multiple calls at once).
Any idea why I would be getting this inconsistent error? Nothing I've been able to find in my investigating indicates which argument of the request is invalid.
Sorry i can't help you. BUT i have the same problem.
I copied and pasted the code from Vertex AI studio into a google colab notebook. Until last Monday everything seemed to work fine, but since Tuesday I'm getting the same error as you almost every time I run it.
Same problem here. Every once in a while this happens, for no obvious reason. I have prompts that when I run them 100 times, it happens at least once. I get an empty response, and I get "FinishReason.SAFETY" then (although the prompts are completely harmless). Retrying until it works (usually at the second try), is the workaround I am applying now.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |