Skip to content

Commit 3f4f863

Browse files
authored
Merge branch 'main' into release-please--branches--main
2 parents b86c158 + 88848eb commit 3f4f863

93 files changed

Lines changed: 13264 additions & 2071 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/google-ai-generativelanguage/google/ai/generativelanguage/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.6.2" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.6.2" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/async_client.py

Lines changed: 58 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import (
2020
AsyncIterable,
2121
Awaitable,
22+
Callable,
2223
Dict,
2324
Mapping,
2425
MutableMapping,
@@ -201,7 +202,13 @@ def __init__(
201202
self,
202203
*,
203204
credentials: Optional[ga_credentials.Credentials] = None,
204-
transport: Union[str, GenerativeServiceTransport] = "grpc_asyncio",
205+
transport: Optional[
206+
Union[
207+
str,
208+
GenerativeServiceTransport,
209+
Callable[..., GenerativeServiceTransport],
210+
]
211+
] = "grpc_asyncio",
205212
client_options: Optional[ClientOptions] = None,
206213
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
207214
) -> None:
@@ -213,9 +220,11 @@ def __init__(
213220
credentials identify the application to the service; if none
214221
are specified, the client will attempt to ascertain the
215222
credentials from the environment.
216-
transport (Union[str, ~.GenerativeServiceTransport]): The
217-
transport to use. If set to None, a transport is chosen
218-
automatically.
223+
transport (Optional[Union[str,GenerativeServiceTransport,Callable[..., GenerativeServiceTransport]]]):
224+
The transport to use, or a Callable that constructs and returns a new transport to use.
225+
If a Callable is given, it will be called with the same set of initialization
226+
arguments as used in the GenerativeServiceTransport constructor.
227+
If set to None, a transport is chosen automatically.
219228
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
220229
Custom options for the client.
221230
@@ -347,16 +356,19 @@ async def sample_generate_content():
347356
348357
"""
349358
# Create or coerce a protobuf request object.
350-
# Quick check: If we got a request object, we should *not* have
351-
# gotten any keyword arguments that map to the request.
359+
# - Quick check: If we got a request object, we should *not* have
360+
# gotten any keyword arguments that map to the request.
352361
has_flattened_params = any([model, contents])
353362
if request is not None and has_flattened_params:
354363
raise ValueError(
355364
"If the `request` argument is set, then none of "
356365
"the individual field arguments should be set."
357366
)
358367

359-
request = generative_service.GenerateContentRequest(request)
368+
# - Use the request object if provided (there's no risk of modifying the input as
369+
# there are no flattened fields), or create one.
370+
if not isinstance(request, generative_service.GenerateContentRequest):
371+
request = generative_service.GenerateContentRequest(request)
360372

361373
# If we have keyword arguments corresponding to fields on the
362374
# request, apply these.
@@ -367,20 +379,9 @@ async def sample_generate_content():
367379

368380
# Wrap the RPC method; this adds retry and timeout information,
369381
# and friendly error handling.
370-
rpc = gapic_v1.method_async.wrap_method(
371-
self._client._transport.generate_content,
372-
default_retry=retries.AsyncRetry(
373-
initial=1.0,
374-
maximum=10.0,
375-
multiplier=1.3,
376-
predicate=retries.if_exception_type(
377-
core_exceptions.ServiceUnavailable,
378-
),
379-
deadline=60.0,
380-
),
381-
default_timeout=60.0,
382-
client_info=DEFAULT_CLIENT_INFO,
383-
)
382+
rpc = self._client._transport._wrapped_methods[
383+
self._client._transport.generate_content
384+
]
384385

385386
# Certain fields should be provided within the metadata header;
386387
# add these here.
@@ -491,16 +492,19 @@ async def sample_stream_generate_content():
491492
492493
"""
493494
# Create or coerce a protobuf request object.
494-
# Quick check: If we got a request object, we should *not* have
495-
# gotten any keyword arguments that map to the request.
495+
# - Quick check: If we got a request object, we should *not* have
496+
# gotten any keyword arguments that map to the request.
496497
has_flattened_params = any([model, contents])
497498
if request is not None and has_flattened_params:
498499
raise ValueError(
499500
"If the `request` argument is set, then none of "
500501
"the individual field arguments should be set."
501502
)
502503

503-
request = generative_service.GenerateContentRequest(request)
504+
# - Use the request object if provided (there's no risk of modifying the input as
505+
# there are no flattened fields), or create one.
506+
if not isinstance(request, generative_service.GenerateContentRequest):
507+
request = generative_service.GenerateContentRequest(request)
504508

505509
# If we have keyword arguments corresponding to fields on the
506510
# request, apply these.
@@ -511,20 +515,9 @@ async def sample_stream_generate_content():
511515

512516
# Wrap the RPC method; this adds retry and timeout information,
513517
# and friendly error handling.
514-
rpc = gapic_v1.method_async.wrap_method(
515-
self._client._transport.stream_generate_content,
516-
default_retry=retries.AsyncRetry(
517-
initial=1.0,
518-
maximum=10.0,
519-
multiplier=1.3,
520-
predicate=retries.if_exception_type(
521-
core_exceptions.ServiceUnavailable,
522-
),
523-
deadline=60.0,
524-
),
525-
default_timeout=60.0,
526-
client_info=DEFAULT_CLIENT_INFO,
527-
)
518+
rpc = self._client._transport._wrapped_methods[
519+
self._client._transport.stream_generate_content
520+
]
528521

529522
# Certain fields should be provided within the metadata header;
530523
# add these here.
@@ -619,16 +612,19 @@ async def sample_embed_content():
619612
The response to an EmbedContentRequest.
620613
"""
621614
# Create or coerce a protobuf request object.
622-
# Quick check: If we got a request object, we should *not* have
623-
# gotten any keyword arguments that map to the request.
615+
# - Quick check: If we got a request object, we should *not* have
616+
# gotten any keyword arguments that map to the request.
624617
has_flattened_params = any([model, content])
625618
if request is not None and has_flattened_params:
626619
raise ValueError(
627620
"If the `request` argument is set, then none of "
628621
"the individual field arguments should be set."
629622
)
630623

631-
request = generative_service.EmbedContentRequest(request)
624+
# - Use the request object if provided (there's no risk of modifying the input as
625+
# there are no flattened fields), or create one.
626+
if not isinstance(request, generative_service.EmbedContentRequest):
627+
request = generative_service.EmbedContentRequest(request)
632628

633629
# If we have keyword arguments corresponding to fields on the
634630
# request, apply these.
@@ -639,20 +635,9 @@ async def sample_embed_content():
639635

640636
# Wrap the RPC method; this adds retry and timeout information,
641637
# and friendly error handling.
642-
rpc = gapic_v1.method_async.wrap_method(
643-
self._client._transport.embed_content,
644-
default_retry=retries.AsyncRetry(
645-
initial=1.0,
646-
maximum=10.0,
647-
multiplier=1.3,
648-
predicate=retries.if_exception_type(
649-
core_exceptions.ServiceUnavailable,
650-
),
651-
deadline=60.0,
652-
),
653-
default_timeout=60.0,
654-
client_info=DEFAULT_CLIENT_INFO,
655-
)
638+
rpc = self._client._transport._wrapped_methods[
639+
self._client._transport.embed_content
640+
]
656641

657642
# Certain fields should be provided within the metadata header;
658643
# add these here.
@@ -756,16 +741,19 @@ async def sample_batch_embed_contents():
756741
The response to a BatchEmbedContentsRequest.
757742
"""
758743
# Create or coerce a protobuf request object.
759-
# Quick check: If we got a request object, we should *not* have
760-
# gotten any keyword arguments that map to the request.
744+
# - Quick check: If we got a request object, we should *not* have
745+
# gotten any keyword arguments that map to the request.
761746
has_flattened_params = any([model, requests])
762747
if request is not None and has_flattened_params:
763748
raise ValueError(
764749
"If the `request` argument is set, then none of "
765750
"the individual field arguments should be set."
766751
)
767752

768-
request = generative_service.BatchEmbedContentsRequest(request)
753+
# - Use the request object if provided (there's no risk of modifying the input as
754+
# there are no flattened fields), or create one.
755+
if not isinstance(request, generative_service.BatchEmbedContentsRequest):
756+
request = generative_service.BatchEmbedContentsRequest(request)
769757

770758
# If we have keyword arguments corresponding to fields on the
771759
# request, apply these.
@@ -776,20 +764,9 @@ async def sample_batch_embed_contents():
776764

777765
# Wrap the RPC method; this adds retry and timeout information,
778766
# and friendly error handling.
779-
rpc = gapic_v1.method_async.wrap_method(
780-
self._client._transport.batch_embed_contents,
781-
default_retry=retries.AsyncRetry(
782-
initial=1.0,
783-
maximum=10.0,
784-
multiplier=1.3,
785-
predicate=retries.if_exception_type(
786-
core_exceptions.ServiceUnavailable,
787-
),
788-
deadline=60.0,
789-
),
790-
default_timeout=60.0,
791-
client_info=DEFAULT_CLIENT_INFO,
792-
)
767+
rpc = self._client._transport._wrapped_methods[
768+
self._client._transport.batch_embed_contents
769+
]
793770

794771
# Certain fields should be provided within the metadata header;
795772
# add these here.
@@ -890,16 +867,19 @@ async def sample_count_tokens():
890867
891868
"""
892869
# Create or coerce a protobuf request object.
893-
# Quick check: If we got a request object, we should *not* have
894-
# gotten any keyword arguments that map to the request.
870+
# - Quick check: If we got a request object, we should *not* have
871+
# gotten any keyword arguments that map to the request.
895872
has_flattened_params = any([model, contents])
896873
if request is not None and has_flattened_params:
897874
raise ValueError(
898875
"If the `request` argument is set, then none of "
899876
"the individual field arguments should be set."
900877
)
901878

902-
request = generative_service.CountTokensRequest(request)
879+
# - Use the request object if provided (there's no risk of modifying the input as
880+
# there are no flattened fields), or create one.
881+
if not isinstance(request, generative_service.CountTokensRequest):
882+
request = generative_service.CountTokensRequest(request)
903883

904884
# If we have keyword arguments corresponding to fields on the
905885
# request, apply these.
@@ -910,20 +890,9 @@ async def sample_count_tokens():
910890

911891
# Wrap the RPC method; this adds retry and timeout information,
912892
# and friendly error handling.
913-
rpc = gapic_v1.method_async.wrap_method(
914-
self._client._transport.count_tokens,
915-
default_retry=retries.AsyncRetry(
916-
initial=1.0,
917-
maximum=10.0,
918-
multiplier=1.3,
919-
predicate=retries.if_exception_type(
920-
core_exceptions.ServiceUnavailable,
921-
),
922-
deadline=60.0,
923-
),
924-
default_timeout=60.0,
925-
client_info=DEFAULT_CLIENT_INFO,
926-
)
893+
rpc = self._client._transport._wrapped_methods[
894+
self._client._transport.count_tokens
895+
]
927896

928897
# Certain fields should be provided within the metadata header;
929898
# add these here.

0 commit comments

Comments
 (0)