for m in genai.list_models():
if 'generateContent' in m.supported_generation_methods:
print(m.name)
{
"name": "RetryError",
"message": "Timeout of 60.0s exceeded, last exception: 503 failed to connect to all addresses; last error: UNAVAILABLE: ipv4:172.217.160.106:443: TCP stream shutting down",
"stack": "---------------------------------------------------------------------------
_InactiveRpcError Traceback (most recent call last)
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\google\\api_core\\grpc_helpers.py:76, in _wrap_unary_errors.<locals>.error_remapped_callable(*args, **kwargs)
75 try:
---> 76 return callable_(*args, **kwargs)
77 except grpc.RpcError as exc:
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\grpc\\_channel.py:1181, in _UnaryUnaryMultiCallable.__call__(self, request, timeout, metadata, credentials, wait_for_ready, compression)
1175 (
1176 state,
1177 call,
1178 ) = self._blocking(
1179 request, timeout, metadata, credentials, wait_for_ready, compression
1180 )
-> 1181 return _end_unary_response_blocking(state, call, False, None)
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\grpc\\_channel.py:1006, in _end_unary_response_blocking(state, call, with_call, deadline)
1005 else:
-> 1006 raise _InactiveRpcError(state)
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
\tstatus = StatusCode.UNAVAILABLE
\tdetails = \"failed to connect to all addresses; last error: UNAVAILABLE: ipv4:172.217.160.106:443: TCP stream shutting down\"
\tdebug_error_string = \"UNKNOWN:Error received from peer {created_time:\"2024-05-15T03:51:00.3940293+00:00\", grpc_status:14, grpc_message:\"failed to connect to all addresses; last error: UNAVAILABLE: ipv4:172.217.160.106:443: TCP stream shutting down\"}\"
>
The above exception was the direct cause of the following exception:
ServiceUnavailable Traceback (most recent call last)
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\google\\api_core\\retry\\retry_unary.py:144, in retry_target(target, predicate, sleep_generator, timeout, on_error, exception_factory, **kwargs)
143 try:
--> 144 result = target()
145 if inspect.isawaitable(result):
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\google\\api_core\\timeout.py:120, in TimeToDeadlineTimeout.__call__.<locals>.func_with_timeout(*args, **kwargs)
118 kwargs[\"timeout\"] = max(0, self._timeout - time_since_first_attempt)
--> 120 return func(*args, **kwargs)
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\google\\api_core\\grpc_helpers.py:78, in _wrap_unary_errors.<locals>.error_remapped_callable(*args, **kwargs)
77 except grpc.RpcError as exc:
---> 78 raise exceptions.from_grpc_error(exc) from exc
ServiceUnavailable: 503 failed to connect to all addresses; last error: UNAVAILABLE: ipv4:172.217.160.106:443: TCP stream shutting down
The above exception was the direct cause of the following exception:
RetryError Traceback (most recent call last)
Cell In[4], line 1
----> 1 for m in genai.list_models():
2 if 'generateContent' in m.supported_generation_methods:
3 print(m.name)
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\google\\generativeai\\models.py:190, in list_models(page_size, client, request_options)
187 if client is None:
188 client = get_default_model_client()
--> 190 for model in client.list_models(page_size=page_size, **request_options):
191 model = type(model).to_dict(model)
192 yield model_types.Model(**model)
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\google\\ai\\generativelanguage_v1beta\\services\\model_service\\client.py:910, in ModelServiceClient.list_models(self, request, page_size, page_token, retry, timeout, metadata)
907 self._validate_universe_domain()
909 # Send the request.
--> 910 response = rpc(
911 request,
912 retry=retry,
913 timeout=timeout,
914 metadata=metadata,
915 )
917 # This method is paged; wrap the response in a pager, which provides
918 # an `__iter__` convenience method.
919 response = pagers.ListModelsPager(
920 method=rpc,
921 request=request,
922 response=response,
923 metadata=metadata,
924 )
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\google\\api_core\\gapic_v1\\method.py:131, in _GapicCallable.__call__(self, timeout, retry, compression, *args, **kwargs)
128 if self._compression is not None:
129 kwargs[\"compression\"] = compression
--> 131 return wrapped_func(*args, **kwargs)
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\google\\api_core\\retry\\retry_unary.py:293, in Retry.__call__.<locals>.retry_wrapped_func(*args, **kwargs)
289 target = functools.partial(func, *args, **kwargs)
290 sleep_generator = exponential_sleep_generator(
291 self._initial, self._maximum, multiplier=self._multiplier
292 )
--> 293 return retry_target(
294 target,
295 self._predicate,
296 sleep_generator,
297 timeout=self._timeout,
298 on_error=on_error,
299 )
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\google\\api_core\\retry\\retry_unary.py:153, in retry_target(target, predicate, sleep_generator, timeout, on_error, exception_factory, **kwargs)
149 # pylint: disable=broad-except
150 # This function explicitly must deal with broad exceptions.
151 except Exception as exc:
152 # defer to shared logic for handling errors
--> 153 _retry_error_helper(
154 exc,
155 deadline,
156 sleep,
157 error_list,
158 predicate,
159 on_error,
160 exception_factory,
161 timeout,
162 )
163 # if exception not raised, sleep before next attempt
164 time.sleep(sleep)
File c:\\Users\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\google\\api_core\\retry\\retry_base.py:221, in _retry_error_helper(exc, deadline, next_sleep, error_list, predicate_fn, on_error_fn, exc_factory_fn, original_timeout)
215 if deadline is not None and time.monotonic() + next_sleep > deadline:
216 final_exc, source_exc = exc_factory_fn(
217 error_list,
218 RetryFailureReason.TIMEOUT,
219 original_timeout,
220 )
--> 221 raise final_exc from source_exc
222 _LOGGER.debug(
223 \"Retrying due to {}, sleeping {:.1f}s ...\".format(error_list[-1], next_sleep)
224 )
RetryError: Timeout of 60.0s exceeded, last exception: 503 failed to connect to all addresses; last error: UNAVAILABLE: ipv4:172.217.160.106:443: TCP stream shutting down"
}