Getting Started with Google Generative AI Using the Gen AI SDK Reviews
141285 reviews
I keep getting the following error: --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[7], line 1 ----> 1 response = client.models.generate_content( 2 model=MODEL_ID, contents="What's the largest planet in our solar system?" 3 ) 5 print(response.text) File /opt/conda/lib/python3.10/site-packages/google/genai/models.py:6003, in Models.generate_content(self, model, contents, config) 6001 while remaining_remote_calls_afc > 0: 6002 i += 1 -> 6003 response = self._generate_content( 6004 model=model, contents=contents, config=parsed_config 6005 ) 6007 function_map = _extra_utils.get_function_map(parsed_config) 6008 if not function_map: File /opt/conda/lib/python3.10/site-packages/google/genai/models.py:4683, in Models._generate_content(self, model, contents, config) 4680 request_dict = _common.convert_to_dict(request_dict) 4681 request_dict = _common.encode_unserializable_types(request_dict) -> 4683 response = self._api_client.request( 4684 'post', path, request_dict, http_options 4685 ) 4687 if config is not None and getattr( 4688 config, 'should_return_http_response', None 4689 ): 4690 return_value = types.GenerateContentResponse(sdk_http_response=response) File /opt/conda/lib/python3.10/site-packages/google/genai/_api_client.py:1532, in BaseApiClient.request(self, http_method, path, request_dict, http_options) 1522 def request( 1523 self, 1524 http_method: str, (...) 1527 http_options: Optional[HttpOptionsOrDict] = None, 1528 ) -> SdkHttpResponse: 1529 http_request = self._build_request( 1530 http_method, path, request_dict, http_options 1531 ) -> 1532 response = self._request(http_request, http_options, stream=False) 1533 response_body = ( 1534 response.response_stream[0] if response.response_stream else '' 1535 ) 1536 return SdkHttpResponse(headers=response.headers, body=response_body) File /opt/conda/lib/python3.10/site-packages/google/genai/_api_client.py:1327, in BaseApiClient._request(self, http_request, http_options, stream) 1324 retry = tenacity.Retrying(**retry_kwargs) 1325 return retry(self._request_once, http_request, stream) # type: ignore[no-any-return] -> 1327 return self._retry(self._request_once, http_request, stream) File /opt/conda/lib/python3.10/site-packages/tenacity/__init__.py:470, in Retrying.__call__(self, fn, *args, **kwargs) 468 retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs) 469 while True: --> 470 do = self.iter(retry_state=retry_state) 471 if isinstance(do, DoAttempt): 472 try: File /opt/conda/lib/python3.10/site-packages/tenacity/__init__.py:371, in BaseRetrying.iter(self, retry_state) 369 result = None 370 for action in self.iter_state.actions: --> 371 result = action(retry_state) 372 return result File /opt/conda/lib/python3.10/site-packages/tenacity/__init__.py:413, in BaseRetrying._post_stop_check_actions.<locals>.exc_check(rs) 411 retry_exc = self.retry_error_cls(fut) 412 if self.reraise: --> 413 raise retry_exc.reraise() 414 raise retry_exc from fut.exception() File /opt/conda/lib/python3.10/site-packages/tenacity/__init__.py:184, in RetryError.reraise(self) 182 def reraise(self) -> t.NoReturn: 183 if self.last_attempt.failed: --> 184 raise self.last_attempt.result() 185 raise self File /opt/conda/lib/python3.10/concurrent/futures/_base.py:451, in Future.result(self, timeout) 449 raise CancelledError() 450 elif self._state == FINISHED: --> 451 return self.__get_result() 453 self._condition.wait(timeout) 455 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: File /opt/conda/lib/python3.10/concurrent/futures/_base.py:403, in Future.__get_result(self) 401 if self._exception: 402 try: --> 403 raise self._exception 404 finally: 405 # Break a reference cycle with the exception in self._exception 406 self = None File /opt/conda/lib/python3.10/site-packages/tenacity/__init__.py:473, in Retrying.__call__(self, fn, *args, **kwargs) 471 if isinstance(do, DoAttempt): 472 try: --> 473 result = fn(*args, **kwargs) 474 except BaseException: # noqa: B902 475 retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type] File /opt/conda/lib/python3.10/site-packages/google/genai/_api_client.py:1256, in BaseApiClient._request_once(self, http_request, stream) 1254 # If using proj/location, fetch ADC 1255 if self.vertexai and (self.project or self.location): -> 1256 http_request.headers['Authorization'] = f'Bearer {self._access_token()}' 1257 if self._credentials and self._credentials.quota_project_id: 1258 http_request.headers['x-goog-user-project'] = ( 1259 self._credentials.quota_project_id 1260 ) File /opt/conda/lib/python3.10/site-packages/google/genai/_api_client.py:1084, in BaseApiClient._access_token(self) 1082 with self._sync_auth_lock: 1083 if not self._credentials: -> 1084 self._credentials, project = load_auth(project=self.project) 1085 if not self.project: 1086 self.project = project File /opt/conda/lib/python3.10/site-packages/google/genai/_api_client.py:190, in load_auth(project) 188 def load_auth(*, project: Union[str, None]) -> Tuple[Credentials, str]: 189 """Loads google auth credentials and project id.""" --> 190 credentials, loaded_project_id = google.auth.default( # type: ignore[no-untyped-call] 191 scopes=['https://www.googleapis.com/auth/cloud-platform'], 192 ) 194 if not project: 195 project = loaded_project_id File /opt/conda/lib/python3.10/site-packages/google/auth/_default.py:705, in default(scopes, request, quota_project_id, default_scopes) 0 <Error retrieving source code with stack_data see ipython/ipython#13598> File /opt/conda/lib/python3.10/site-packages/google/auth/_default.py:701, in <lambda>() 0 <Error retrieving source code with stack_data see ipython/ipython#13598> File /opt/conda/lib/python3.10/site-packages/google/auth/_default.py:395, in _get_gce_credentials(request, quota_project_id) 391 def _get_gce_credentials(request=None, quota_project_id=None): 392 """Gets credentials and project ID from the GCE Metadata Service.""" 393 # Ping requires a transport, but we want application default credentials 394 # to require no arguments. So, we'll use the _http_client transport which --> 395 # uses http.client. This is only acceptable because the metadata server 396 # doesn't do SSL and never requires proxies. 397 398 # While this library is normally bundled with compute_engine, there are 399 # some cases where it's not available, so we tolerate ImportError. 400 try: 401 from google.auth import compute_engine File /opt/conda/lib/python3.10/site-packages/google/auth/compute_engine/__init__.py:17 1 # Copyright 2016 Google LLC 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); (...) 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 15 """Google Compute Engine authentication.""" ---> 17 from google.auth.compute_engine._metadata import detect_gce_residency_linux 18 from google.auth.compute_engine.credentials import Credentials 19 from google.auth.compute_engine.credentials import IDTokenCredentials File /opt/conda/lib/python3.10/site-packages/google/auth/compute_engine/_metadata.py:100 97 # Timeout in seconds to wait for the GCE metadata server when detecting the 98 # GCE environment. 99 try: --> 100 _METADATA_DEFAULT_TIMEOUT = int(os.getenv(environment_vars.GCE_METADATA_TIMEOUT, 3)) 101 except ValueError: # pragma: NO COVER 102 _METADATA_DEFAULT_TIMEOUT = 3 AttributeError: module 'google.auth.environment_vars' has no attribute 'GCE_METADATA_TIMEOUT'
Branko N. · Reviewed 7 minutes ago
Chartnayodom W. · Reviewed 35 minutes ago
C VARSHA U. · Reviewed 1 hour ago
Armand A. · Reviewed 1 hour ago
Swathi J. · Reviewed 1 hour ago
모델 running이 안됨
주현 이. · Reviewed 2 hours ago
Amulya C. · Reviewed 2 hours ago
Adeeb A. · Reviewed 2 hours ago
Deepika M. · Reviewed 2 hours ago
Pradip K. · Reviewed 2 hours ago
Divyaraj P. · Reviewed 2 hours ago
Riya K. · Reviewed 2 hours ago
Nagaraj C. · Reviewed 2 hours ago
B J. · Reviewed 2 hours ago
Darshan M. · Reviewed 2 hours ago
Sachin R. · Reviewed 2 hours ago
Subashan Kaveri S G. · Reviewed 2 hours ago
Febin S. · Reviewed 2 hours ago
Tamanna R. · Reviewed 2 hours ago
Good
Sriparna B. · Reviewed 2 hours ago
good
Santosh K. · Reviewed 2 hours ago
Taekyeong L. · Reviewed 2 hours ago
Abu B. · Reviewed 3 hours ago
Santosh K. · Reviewed 3 hours ago
JJin B. · Reviewed 3 hours ago
We do not ensure the published reviews originate from consumers who have purchased or used the products. Reviews are not verified by Google.