Getting Started with Google Generative AI Using the Gen AI SDK Reviews

140716 reviews

Paulo N. · Reviewed 7 أيام ago

Teerapat Y. · Reviewed 7 أيام ago

Julian U. · Reviewed 7 أيام ago

Nirvigna D. · Reviewed 7 أيام ago

notebook with lot of old code issues.

Rohit V R. · Reviewed 7 أيام ago

MANOGNA G. · Reviewed 7 أيام ago

good

veeraragavan G G. · Reviewed 7 أيام ago

Starting from "Send text prompts" with this step response = client.models.generate_content( model=MODEL_ID, contents="What's the largest planet in our solar system?" ) I was always getting this error: print(response.text) AttributeError: module 'google.auth.environment_vars' has no attribute 'GCE_METADATA_TIMEOUT' Full Error: AttributeError Traceback (most recent call last) Cell In[31], 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/envs/tensorflow/lib/python3.10/site-packages/google/genai/models.py:5864, in Models.generate_content(self, model, contents, config) 5862 while remaining_remote_calls_afc > 0: 5863 i += 1 -> 5864 response = self._generate_content( 5865 model=model, contents=contents, config=parsed_config 5866 ) 5868 function_map = _extra_utils.get_function_map(parsed_config) 5869 if not function_map: File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/google/genai/models.py:4526, in Models._generate_content(self, model, contents, config) 4523 request_dict = _common.convert_to_dict(request_dict) 4524 request_dict = _common.encode_unserializable_types(request_dict) -> 4526 response = self._api_client.request( 4527 'post', path, request_dict, http_options 4528 ) 4530 if config is not None and getattr( 4531 config, 'should_return_http_response', None 4532 ): 4533 return_value = types.GenerateContentResponse(sdk_http_response=response) File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/google/genai/_api_client.py:1402, in BaseApiClient.request(self, http_method, path, request_dict, http_options) 1392 def request( 1393 self, 1394 http_method: str, (...) 1397 http_options: Optional[HttpOptionsOrDict] = None, 1398 ) -> SdkHttpResponse: 1399 http_request = self._build_request( 1400 http_method, path, request_dict, http_options 1401 ) -> 1402 response = self._request(http_request, http_options, stream=False) 1403 response_body = ( 1404 response.response_stream[0] if response.response_stream else '' 1405 ) 1406 return SdkHttpResponse(headers=response.headers, body=response_body) File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/google/genai/_api_client.py:1238, in BaseApiClient._request(self, http_request, http_options, stream) 1235 retry = tenacity.Retrying(**retry_kwargs) 1236 return retry(self._request_once, http_request, stream) # type: ignore[no-any-return] -> 1238 return self._retry(self._request_once, http_request, stream) File /opt/conda/envs/tensorflow/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/envs/tensorflow/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/envs/tensorflow/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/envs/tensorflow/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/envs/tensorflow/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/envs/tensorflow/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/envs/tensorflow/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/envs/tensorflow/lib/python3.10/site-packages/google/genai/_api_client.py:1181, in BaseApiClient._request_once(self, http_request, stream) 1179 # If using proj/location, fetch ADC 1180 if self.vertexai and (self.project or self.location): -> 1181 http_request.headers['Authorization'] = f'Bearer {self._access_token()}' 1182 if self._credentials and self._credentials.quota_project_id: 1183 http_request.headers['x-goog-user-project'] = ( 1184 self._credentials.quota_project_id 1185 ) File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/google/genai/_api_client.py:1009, in BaseApiClient._access_token(self) 1007 with self._sync_auth_lock: 1008 if not self._credentials: -> 1009 self._credentials, project = load_auth(project=self.project) 1010 if not self.project: 1011 self.project = project File /opt/conda/envs/tensorflow/lib/python3.10/site-packages/google/genai/_api_client.py:191, in load_auth(project) 185 ## Set GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES to false 186 ## to disable bound token sharing. Tracking on 187 ## https://github.com/googleapis/python-genai/issues/1956 188 os.environ['GOOGLE_API_PREVENT_AGENT_TOKEN_SHARING_FOR_GCP_SERVICES'] = ( 189 'false' 190 ) --> 191 credentials, loaded_project_id = google.auth.default( # type: ignore[no-untyped-call] 192 scopes=['https://www.googleapis.com/auth/cloud-platform'], 193 ) 195 if not project: 196 project = loaded_project_id File /opt/conda/envs/tensorflow/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/envs/tensorflow/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/envs/tensorflow/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/envs/tensorflow/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/envs/tensorflow/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'

Willy K. · Reviewed 7 أيام ago

good learning

Abu O. · Reviewed 7 أيام ago

Girish Chand K. · Reviewed 7 أيام ago

goog

Shifana Thaslim S. · Reviewed 7 أيام ago

Madhu R. · Reviewed 7 أيام ago

satisfied

Mohana p. · Reviewed 7 أيام ago

Naveen M. · Reviewed 7 أيام ago

Jaya Naga Manikanta K. · Reviewed 7 أيام ago

Taufiq G. · Reviewed 7 أيام ago

Gowtham R. · Reviewed 7 أيام ago

Amarendra G. · Reviewed 7 أيام ago

Akhilesh E. · Reviewed 7 أيام ago

Sri ramya K. · Reviewed 7 أيام ago

Kamalesh M. · Reviewed 7 أيام ago

Gopi nadh A. · Reviewed 7 أيام ago

Lakshmi bhavani N. · Reviewed 7 أيام ago

Moora S. · Reviewed 7 أيام ago

Sobhasmita M. · Reviewed 7 أيام ago

We do not ensure the published reviews originate from consumers who have purchased or used the products. Reviews are not verified by Google.