Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow user to create Part from function_call #3196

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Copybara import of the project:
--
3a6f33f by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

fix!:An existing message `UnprotectedResource` is removed
feat:A new message `UnprotectedResourceReportLog` is added

PiperOrigin-RevId: 596551504

Source-Link: googleapis/googleapis@9fb44f1

Source-Link: https://github.com/googleapis/googleapis-gen/commit/8bf21f2c64a79508ebb214a2984ef3dd737d3947
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOGJmMjFmMmM2NGE3OTUwOGViYjIxNGEyOTg0ZWYzZGQ3MzdkMzk0NyJ9

--
a960edb by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

--
9f63fdb by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

fix!: Fix rpc tensorboard_service.proto definitions for BatchCreateTensorboardTimeSeries and BatchReadTensorboardTimeSeriesData
feat: add models to CustomJobSpec
feat: add max_wait_duration to Scheduling
docs: minor changes to comments

PiperOrigin-RevId: 597666793

Source-Link: googleapis/googleapis@84ee19c

Source-Link: https://github.com/googleapis/googleapis-gen/commit/8dc3e3e32043acd6893bed96a6b4566f00843329
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOGRjM2UzZTMyMDQzYWNkNjg5M2JlZDk2YTZiNDU2NmYwMDg0MzMyOSJ9

--
f9c4acb by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

--
2ca1fd4 by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

fix!: Fix rpc tensorboard_service.proto definitions for BatchCreateTensorboardTimeSeries and BatchReadTensorboardTimeSeriesData
feat: add models to CustomJobSpec
feat: add max_wait_duration to Scheduling
feat: add CountTokens method to llm_utility_service
docs: minor changes to comments

PiperOrigin-RevId: 597667108

Source-Link: googleapis/googleapis@714ab03

Source-Link: https://github.com/googleapis/googleapis-gen/commit/3ff71b39d2ad2eeb5113940c5de5593da0527b26
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiM2ZmNzFiMzlkMmFkMmVlYjUxMTM5NDBjNWRlNTU5M2RhMDUyN2IyNiJ9

--
24299c0 by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

COPYBARA_INTEGRATE_REVIEW=#3172 from googleapis:owl-bot-copy 9e9bb6a
PiperOrigin-RevId: 597890211
  • Loading branch information
gcf-owl-bot[bot] authored and ehaca committed Jan 12, 2024
commit d69a8945ebd575a6bc07b4b335eeddc6506c6217
Original file line number Diff line number Diff line change
@@ -325,7 +325,7 @@ async def sample_create_feature_online_store():
parent (:class:`str`):
Required. The resource name of the Location to create
FeatureOnlineStores. Format:
``projects/{project}/locations/{location}'``
``projects/{project}/locations/{location}``

This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
Original file line number Diff line number Diff line change
@@ -581,7 +581,7 @@ def sample_create_feature_online_store():
parent (str):
Required. The resource name of the Location to create
FeatureOnlineStores. Format:
``projects/{project}/locations/{location}'``
``projects/{project}/locations/{location}``

This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
29 changes: 29 additions & 0 deletions google/cloud/aiplatform_v1/types/custom_job.py
Original file line number Diff line number Diff line change
@@ -283,6 +283,22 @@ class CustomJobSpec(proto.Message):
Optional. The Experiment Run associated with this job.
Format:
``projects/{project}/locations/{location}/metadataStores/{metadataStores}/contexts/{experiment-name}-{experiment-run-name}``
models (MutableSequence[str]):
Optional. The name of the Model resources for which to
generate a mapping to artifact URIs. Applicable only to some
of the Google-provided custom jobs. Format:
``projects/{project}/locations/{location}/models/{model}``

In order to retrieve a specific version of the model, also
provide the version ID or version alias. Example:
``projects/{project}/locations/{location}/models/{model}@2``
or
``projects/{project}/locations/{location}/models/{model}@golden``
If no version ID or alias is specified, the "default"
version will be returned. The "default" version alias is
created for the first version of the model, and can be moved
to other versions later on. There will be exactly one
default version.
"""

worker_pool_specs: MutableSequence["WorkerPoolSpec"] = proto.RepeatedField(
@@ -336,6 +352,10 @@ class CustomJobSpec(proto.Message):
proto.STRING,
number=18,
)
models: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=20,
)


class WorkerPoolSpec(proto.Message):
@@ -509,6 +529,10 @@ class Scheduling(proto.Message):
Optional. Indicates if the job should retry for internal
errors after the job starts running. If true, overrides
``Scheduling.restart_job_on_worker_restart`` to false.
max_wait_duration (google.protobuf.duration_pb2.Duration):
Optional. This is the maximum time a user
will wait in the QRM queue for resources.
Default is 1 day
"""

timeout: duration_pb2.Duration = proto.Field(
@@ -524,6 +548,11 @@ class Scheduling(proto.Message):
proto.BOOL,
number=5,
)
max_wait_duration: duration_pb2.Duration = proto.Field(
proto.MESSAGE,
number=6,
message=duration_pb2.Duration,
)


__all__ = tuple(sorted(__protobuf__.manifest))
4 changes: 2 additions & 2 deletions google/cloud/aiplatform_v1/types/dataset_service.py
Original file line number Diff line number Diff line change
@@ -352,8 +352,8 @@ class ExportDataResponse(proto.Message):
exported_files (MutableSequence[str]):
All of the files that are exported in this export operation.
For custom code training export, only three (training,
validation and test) GCS paths in wildcard format are
populated (e.g., gs://.../training-*).
validation and test) Cloud Storage paths in wildcard format
are populated (for example, gs://.../training-*).
data_stats (google.cloud.aiplatform_v1.types.Model.DataStats):
Only present for custom code training export
use case. Records data stats, i.e.,
4 changes: 2 additions & 2 deletions google/cloud/aiplatform_v1/types/feature.py
Original file line number Diff line number Diff line change
@@ -94,8 +94,8 @@ class Feature(proto.Message):
stats and anomalies with specified objectives.
version_column_name (str):
Only applicable for Vertex AI Feature Store. The name of the
BigQuery Table/View columnn hosting data for this version.
If no value is provided, will use feature_id.
BigQuery Table/View column hosting data for this version. If
no value is provided, will use feature_id.
"""

class ValueType(proto.Enum):
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ class CreateFeatureOnlineStoreRequest(proto.Message):
parent (str):
Required. The resource name of the Location to create
FeatureOnlineStores. Format:
``projects/{project}/locations/{location}'``
``projects/{project}/locations/{location}``
feature_online_store (google.cloud.aiplatform_v1.types.FeatureOnlineStore):
Required. The FeatureOnlineStore to create.
feature_online_store_id (str):
3 changes: 2 additions & 1 deletion google/cloud/aiplatform_v1/types/model_evaluation.py
Original file line number Diff line number Diff line change
@@ -103,7 +103,8 @@ class ModelEvaluation(proto.Message):
The metadata of the ModelEvaluation. For the ModelEvaluation
uploaded from Managed Pipeline, metadata contains a
structured value with keys of "pipeline_job_id",
"evaluation_dataset_type", "evaluation_dataset_path".
"evaluation_dataset_type", "evaluation_dataset_path",
"row_based_metrics_path".
"""

class ModelEvaluationExplanationSpec(proto.Message):
10 changes: 10 additions & 0 deletions google/cloud/aiplatform_v1beta1/gapic_metadata.json
Original file line number Diff line number Diff line change
@@ -1468,6 +1468,11 @@
"methods": [
"compute_tokens"
]
},
"CountTokens": {
"methods": [
"count_tokens"
]
}
}
},
@@ -1478,6 +1483,11 @@
"methods": [
"compute_tokens"
]
},
"CountTokens": {
"methods": [
"count_tokens"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -325,7 +325,7 @@ async def sample_create_feature_online_store():
parent (:class:`str`):
Required. The resource name of the Location to create
FeatureOnlineStores. Format:
``projects/{project}/locations/{location}'``
``projects/{project}/locations/{location}``

This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
Original file line number Diff line number Diff line change
@@ -581,7 +581,7 @@ def sample_create_feature_online_store():
parent (str):
Required. The resource name of the Location to create
FeatureOnlineStores. Format:
``projects/{project}/locations/{location}'``
``projects/{project}/locations/{location}``

This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@
OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore

from google.cloud.aiplatform_v1beta1.types import llm_utility_service
from google.cloud.aiplatform_v1beta1.types import prediction_service
from google.cloud.location import locations_pb2 # type: ignore
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
@@ -217,6 +218,130 @@ def __init__(
client_info=client_info,
)

async def count_tokens(
self,
request: Optional[Union[prediction_service.CountTokensRequest, dict]] = None,
*,
endpoint: Optional[str] = None,
instances: Optional[MutableSequence[struct_pb2.Value]] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> prediction_service.CountTokensResponse:
r"""Perform a token counting.

.. code-block:: python

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import aiplatform_v1beta1

async def sample_count_tokens():
# Create a client
client = aiplatform_v1beta1.LlmUtilityServiceAsyncClient()

# Initialize request argument(s)
instances = aiplatform_v1beta1.Value()
instances.null_value = "NULL_VALUE"

contents = aiplatform_v1beta1.Content()
contents.parts.text = "text_value"

request = aiplatform_v1beta1.CountTokensRequest(
endpoint="endpoint_value",
model="model_value",
instances=instances,
contents=contents,
)

# Make the request
response = await client.count_tokens(request=request)

# Handle the response
print(response)

Args:
request (Optional[Union[google.cloud.aiplatform_v1beta1.types.CountTokensRequest, dict]]):
The request object. Request message for
[PredictionService.CountTokens][google.cloud.aiplatform.v1beta1.PredictionService.CountTokens].
endpoint (:class:`str`):
Required. The name of the Endpoint requested to perform
token counting. Format:
``projects/{project}/locations/{location}/endpoints/{endpoint}``

This corresponds to the ``endpoint`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
instances (:class:`MutableSequence[google.protobuf.struct_pb2.Value]`):
Required. The instances that are the
input to token counting call. Schema is
identical to the prediction schema of
the underlying model.

This corresponds to the ``instances`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.cloud.aiplatform_v1beta1.types.CountTokensResponse:
Response message for
[PredictionService.CountTokens][google.cloud.aiplatform.v1beta1.PredictionService.CountTokens].

"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([endpoint, instances])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

request = prediction_service.CountTokensRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if endpoint is not None:
request.endpoint = endpoint
if instances:
request.instances.extend(instances)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.count_tokens,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("endpoint", request.endpoint),)),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def compute_tokens(
self,
request: Optional[Union[llm_utility_service.ComputeTokensRequest, dict]] = None,
Loading