Skip to content

Commit fafb8a9

Browse files
1 parent 7724559 commit fafb8a9

2,989 files changed

Lines changed: 9422 additions & 2782594 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.

google/cloud/aiplatform_v1beta1/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,11 @@
12971297
from .types.vertex_rag_data_service import UpdateRagEngineConfigRequest
12981298
from .types.vertex_rag_data_service import UploadRagFileRequest
12991299
from .types.vertex_rag_data_service import UploadRagFileResponse
1300+
from .types.vertex_rag_service import AskContextsRequest
1301+
from .types.vertex_rag_service import AskContextsResponse
1302+
from .types.vertex_rag_service import AsyncRetrieveContextsOperationMetadata
1303+
from .types.vertex_rag_service import AsyncRetrieveContextsRequest
1304+
from .types.vertex_rag_service import AsyncRetrieveContextsResponse
13001305
from .types.vertex_rag_service import AugmentPromptRequest
13011306
from .types.vertex_rag_service import AugmentPromptResponse
13021307
from .types.vertex_rag_service import Claim
@@ -1482,6 +1487,8 @@ def _get_version(dependency_name):
14821487
"AppendEventResponse",
14831488
"Artifact",
14841489
"ArtifactTypeSchema",
1490+
"AskContextsRequest",
1491+
"AskContextsResponse",
14851492
"AssembleDataOperationMetadata",
14861493
"AssembleDataRequest",
14871494
"AssembleDataResponse",
@@ -1490,6 +1497,9 @@ def _get_version(dependency_name):
14901497
"AssessDataResponse",
14911498
"AssignNotebookRuntimeOperationMetadata",
14921499
"AssignNotebookRuntimeRequest",
1500+
"AsyncRetrieveContextsOperationMetadata",
1501+
"AsyncRetrieveContextsRequest",
1502+
"AsyncRetrieveContextsResponse",
14931503
"Attribution",
14941504
"AugmentPromptRequest",
14951505
"AugmentPromptResponse",

google/cloud/aiplatform_v1beta1/gapic_metadata.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6364,6 +6364,16 @@
63646364
"grpc": {
63656365
"libraryClient": "VertexRagServiceClient",
63666366
"rpcs": {
6367+
"AskContexts": {
6368+
"methods": [
6369+
"ask_contexts"
6370+
]
6371+
},
6372+
"AsyncRetrieveContexts": {
6373+
"methods": [
6374+
"async_retrieve_contexts"
6375+
]
6376+
},
63676377
"AugmentPrompt": {
63686378
"methods": [
63696379
"augment_prompt"
@@ -6384,6 +6394,16 @@
63846394
"grpc-async": {
63856395
"libraryClient": "VertexRagServiceAsyncClient",
63866396
"rpcs": {
6397+
"AskContexts": {
6398+
"methods": [
6399+
"ask_contexts"
6400+
]
6401+
},
6402+
"AsyncRetrieveContexts": {
6403+
"methods": [
6404+
"async_retrieve_contexts"
6405+
]
6406+
},
63876407
"AugmentPrompt": {
63886408
"methods": [
63896409
"augment_prompt"
@@ -6404,6 +6424,16 @@
64046424
"rest": {
64056425
"libraryClient": "VertexRagServiceClient",
64066426
"rpcs": {
6427+
"AskContexts": {
6428+
"methods": [
6429+
"ask_contexts"
6430+
]
6431+
},
6432+
"AsyncRetrieveContexts": {
6433+
"methods": [
6434+
"async_retrieve_contexts"
6435+
]
6436+
},
64076437
"AugmentPrompt": {
64086438
"methods": [
64096439
"augment_prompt"

google/cloud/aiplatform_v1beta1/services/vertex_rag_service/async_client.py

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
from google.iam.v1 import iam_policy_pb2 # type: ignore
5454
from google.iam.v1 import policy_pb2 # type: ignore
5555
from google.longrunning import operations_pb2 # type: ignore
56+
import google.api_core.operation as operation # type: ignore
57+
import google.api_core.operation_async as operation_async # type: ignore
5658
from .transports.base import VertexRagServiceTransport, DEFAULT_CLIENT_INFO
5759
from .transports.grpc_asyncio import VertexRagServiceGrpcAsyncIOTransport
5860
from .client import VertexRagServiceClient
@@ -702,6 +704,273 @@ async def sample_corroborate_content():
702704
# Done; return the response.
703705
return response
704706

707+
async def ask_contexts(
708+
self,
709+
request: Optional[Union[vertex_rag_service.AskContextsRequest, dict]] = None,
710+
*,
711+
parent: Optional[str] = None,
712+
query: Optional[vertex_rag_service.RagQuery] = None,
713+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
714+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
715+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
716+
) -> vertex_rag_service.AskContextsResponse:
717+
r"""Agentic Retrieval Ask API for RAG.
718+
719+
.. code-block:: python
720+
721+
# This snippet has been automatically generated and should be regarded as a
722+
# code template only.
723+
# It will require modifications to work:
724+
# - It may require correct/in-range values for request initialization.
725+
# - It may require specifying regional endpoints when creating the service
726+
# client as shown in:
727+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
728+
from google.cloud import aiplatform_v1beta1
729+
730+
async def sample_ask_contexts():
731+
# Create a client
732+
client = aiplatform_v1beta1.VertexRagServiceAsyncClient()
733+
734+
# Initialize request argument(s)
735+
query = aiplatform_v1beta1.RagQuery()
736+
query.text = "text_value"
737+
738+
request = aiplatform_v1beta1.AskContextsRequest(
739+
parent="parent_value",
740+
query=query,
741+
)
742+
743+
# Make the request
744+
response = await client.ask_contexts(request=request)
745+
746+
# Handle the response
747+
print(response)
748+
749+
Args:
750+
request (Optional[Union[google.cloud.aiplatform_v1beta1.types.AskContextsRequest, dict]]):
751+
The request object. Agentic Retrieval Ask API for RAG. Request message for
752+
[VertexRagService.AskContexts][google.cloud.aiplatform.v1beta1.VertexRagService.AskContexts].
753+
parent (:class:`str`):
754+
Required. The resource name of the Location from which
755+
to retrieve RagContexts. The users must have permission
756+
to make a call in the project. Format:
757+
``projects/{project}/locations/{location}``.
758+
759+
This corresponds to the ``parent`` field
760+
on the ``request`` instance; if ``request`` is provided, this
761+
should not be set.
762+
query (:class:`google.cloud.aiplatform_v1beta1.types.RagQuery`):
763+
Required. Single RAG retrieve query.
764+
This corresponds to the ``query`` field
765+
on the ``request`` instance; if ``request`` is provided, this
766+
should not be set.
767+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
768+
should be retried.
769+
timeout (float): The timeout for this request.
770+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
771+
sent along with the request as metadata. Normally, each value must be of type `str`,
772+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
773+
be of type `bytes`.
774+
775+
Returns:
776+
google.cloud.aiplatform_v1beta1.types.AskContextsResponse:
777+
Response message for
778+
[VertexRagService.AskContexts][google.cloud.aiplatform.v1beta1.VertexRagService.AskContexts].
779+
780+
"""
781+
# Create or coerce a protobuf request object.
782+
# - Quick check: If we got a request object, we should *not* have
783+
# gotten any keyword arguments that map to the request.
784+
flattened_params = [parent, query]
785+
has_flattened_params = (
786+
len([param for param in flattened_params if param is not None]) > 0
787+
)
788+
if request is not None and has_flattened_params:
789+
raise ValueError(
790+
"If the `request` argument is set, then none of "
791+
"the individual field arguments should be set."
792+
)
793+
794+
# - Use the request object if provided (there's no risk of modifying the input as
795+
# there are no flattened fields), or create one.
796+
if not isinstance(request, vertex_rag_service.AskContextsRequest):
797+
request = vertex_rag_service.AskContextsRequest(request)
798+
799+
# If we have keyword arguments corresponding to fields on the
800+
# request, apply these.
801+
if parent is not None:
802+
request.parent = parent
803+
if query is not None:
804+
request.query = query
805+
806+
# Wrap the RPC method; this adds retry and timeout information,
807+
# and friendly error handling.
808+
rpc = self._client._transport._wrapped_methods[
809+
self._client._transport.ask_contexts
810+
]
811+
812+
# Certain fields should be provided within the metadata header;
813+
# add these here.
814+
metadata = tuple(metadata) + (
815+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
816+
)
817+
818+
# Validate the universe domain.
819+
self._client._validate_universe_domain()
820+
821+
# Send the request.
822+
response = await rpc(
823+
request,
824+
retry=retry,
825+
timeout=timeout,
826+
metadata=metadata,
827+
)
828+
829+
# Done; return the response.
830+
return response
831+
832+
async def async_retrieve_contexts(
833+
self,
834+
request: Optional[
835+
Union[vertex_rag_service.AsyncRetrieveContextsRequest, dict]
836+
] = None,
837+
*,
838+
parent: Optional[str] = None,
839+
query: Optional[vertex_rag_service.RagQuery] = None,
840+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
841+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
842+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
843+
) -> operation_async.AsyncOperation:
844+
r"""Asynchronous API to retrieves relevant contexts for a
845+
query.
846+
847+
.. code-block:: python
848+
849+
# This snippet has been automatically generated and should be regarded as a
850+
# code template only.
851+
# It will require modifications to work:
852+
# - It may require correct/in-range values for request initialization.
853+
# - It may require specifying regional endpoints when creating the service
854+
# client as shown in:
855+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
856+
from google.cloud import aiplatform_v1beta1
857+
858+
async def sample_async_retrieve_contexts():
859+
# Create a client
860+
client = aiplatform_v1beta1.VertexRagServiceAsyncClient()
861+
862+
# Initialize request argument(s)
863+
query = aiplatform_v1beta1.RagQuery()
864+
query.text = "text_value"
865+
866+
request = aiplatform_v1beta1.AsyncRetrieveContextsRequest(
867+
parent="parent_value",
868+
query=query,
869+
)
870+
871+
# Make the request
872+
operation = client.async_retrieve_contexts(request=request)
873+
874+
print("Waiting for operation to complete...")
875+
876+
response = (await operation).result()
877+
878+
# Handle the response
879+
print(response)
880+
881+
Args:
882+
request (Optional[Union[google.cloud.aiplatform_v1beta1.types.AsyncRetrieveContextsRequest, dict]]):
883+
The request object. Request message for
884+
[VertexRagService.AsyncRetrieveContexts][google.cloud.aiplatform.v1beta1.VertexRagService.AsyncRetrieveContexts].
885+
parent (:class:`str`):
886+
Required. The resource name of the Location from which
887+
to retrieve RagContexts. The users must have permission
888+
to make a call in the project. Format:
889+
``projects/{project}/locations/{location}``.
890+
891+
This corresponds to the ``parent`` field
892+
on the ``request`` instance; if ``request`` is provided, this
893+
should not be set.
894+
query (:class:`google.cloud.aiplatform_v1beta1.types.RagQuery`):
895+
Required. Single RAG retrieve query.
896+
This corresponds to the ``query`` field
897+
on the ``request`` instance; if ``request`` is provided, this
898+
should not be set.
899+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
900+
should be retried.
901+
timeout (float): The timeout for this request.
902+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
903+
sent along with the request as metadata. Normally, each value must be of type `str`,
904+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
905+
be of type `bytes`.
906+
907+
Returns:
908+
google.api_core.operation_async.AsyncOperation:
909+
An object representing a long-running operation.
910+
911+
The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.AsyncRetrieveContextsResponse` Response message for
912+
[VertexRagService.AsyncRetrieveContexts][google.cloud.aiplatform.v1beta1.VertexRagService.AsyncRetrieveContexts].
913+
914+
"""
915+
# Create or coerce a protobuf request object.
916+
# - Quick check: If we got a request object, we should *not* have
917+
# gotten any keyword arguments that map to the request.
918+
flattened_params = [parent, query]
919+
has_flattened_params = (
920+
len([param for param in flattened_params if param is not None]) > 0
921+
)
922+
if request is not None and has_flattened_params:
923+
raise ValueError(
924+
"If the `request` argument is set, then none of "
925+
"the individual field arguments should be set."
926+
)
927+
928+
# - Use the request object if provided (there's no risk of modifying the input as
929+
# there are no flattened fields), or create one.
930+
if not isinstance(request, vertex_rag_service.AsyncRetrieveContextsRequest):
931+
request = vertex_rag_service.AsyncRetrieveContextsRequest(request)
932+
933+
# If we have keyword arguments corresponding to fields on the
934+
# request, apply these.
935+
if parent is not None:
936+
request.parent = parent
937+
if query is not None:
938+
request.query = query
939+
940+
# Wrap the RPC method; this adds retry and timeout information,
941+
# and friendly error handling.
942+
rpc = self._client._transport._wrapped_methods[
943+
self._client._transport.async_retrieve_contexts
944+
]
945+
946+
# Certain fields should be provided within the metadata header;
947+
# add these here.
948+
metadata = tuple(metadata) + (
949+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
950+
)
951+
952+
# Validate the universe domain.
953+
self._client._validate_universe_domain()
954+
955+
# Send the request.
956+
response = await rpc(
957+
request,
958+
retry=retry,
959+
timeout=timeout,
960+
metadata=metadata,
961+
)
962+
963+
# Wrap the response in an operation future.
964+
response = operation_async.from_gapic(
965+
response,
966+
self._client._transport.operations_client,
967+
vertex_rag_service.AsyncRetrieveContextsResponse,
968+
metadata_type=vertex_rag_service.AsyncRetrieveContextsOperationMetadata,
969+
)
970+
971+
# Done; return the response.
972+
return response
973+
705974
async def list_operations(
706975
self,
707976
request: Optional[operations_pb2.ListOperationsRequest] = None,

0 commit comments

Comments
 (0)