Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions google/cloud/aiplatform_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@
from .types.tool import FunctionResponsePart
from .types.tool import GoogleMaps
from .types.tool import GoogleSearchRetrieval
from .types.tool import PartialArg
from .types.tool import RagRetrievalConfig
from .types.tool import Retrieval
from .types.tool import RetrievalConfig
Expand Down Expand Up @@ -1752,6 +1753,7 @@
"PairwiseSummarizationQualityResult",
"PairwiseSummarizationQualitySpec",
"Part",
"PartialArg",
"PauseModelDeploymentMonitoringJobRequest",
"PauseScheduleRequest",
"PersistentDiskSpec",
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/aiplatform_v1/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,7 @@
FunctionResponsePart,
GoogleMaps,
GoogleSearchRetrieval,
PartialArg,
RagRetrievalConfig,
Retrieval,
RetrievalConfig,
Expand Down Expand Up @@ -2078,6 +2079,7 @@
"FunctionResponsePart",
"GoogleMaps",
"GoogleSearchRetrieval",
"PartialArg",
"RagRetrievalConfig",
"Retrieval",
"RetrievalConfig",
Expand Down
107 changes: 102 additions & 5 deletions google/cloud/aiplatform_v1/types/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"UrlContext",
"FunctionDeclaration",
"FunctionCall",
"PartialArg",
"FunctionResponsePart",
"FunctionResponseBlob",
"FunctionResponseFileData",
Expand Down Expand Up @@ -265,7 +266,7 @@ class Environment(proto.Enum):
)
url_context: "UrlContext" = proto.Field(
proto.MESSAGE,
number=8,
number=10,
message="UrlContext",
)
computer_use: ComputerUse = proto.Field(
Expand Down Expand Up @@ -391,12 +392,22 @@ class FunctionCall(proto.Message):

Attributes:
name (str):
Required. The name of the function to call. Matches
Optional. The name of the function to call. Matches
[FunctionDeclaration.name].
args (google.protobuf.struct_pb2.Struct):
Optional. Required. The function parameters and values in
JSON object format. See [FunctionDeclaration.parameters] for
parameter details.
Optional. The function parameters and values in JSON object
format. See [FunctionDeclaration.parameters] for parameter
details.
partial_args (MutableSequence[google.cloud.aiplatform_v1.types.PartialArg]):
Optional. The partial argument value of the
function call. If provided, represents the
arguments/fields that are streamed
incrementally.
will_continue (bool):
Optional. Whether this is the last part of
the FunctionCall. If true, another partial
message for the current FunctionCall is expected
to follow.
"""

name: str = proto.Field(
Expand All @@ -408,6 +419,83 @@ class FunctionCall(proto.Message):
number=2,
message=struct_pb2.Struct,
)
partial_args: MutableSequence["PartialArg"] = proto.RepeatedField(
proto.MESSAGE,
number=4,
message="PartialArg",
)
will_continue: bool = proto.Field(
proto.BOOL,
number=5,
)


class PartialArg(proto.Message):
r"""Partial argument value of the function call.

This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Attributes:
null_value (google.protobuf.struct_pb2.NullValue):
Optional. Represents a null value.

This field is a member of `oneof`_ ``delta``.
number_value (float):
Optional. Represents a double value.

This field is a member of `oneof`_ ``delta``.
string_value (str):
Optional. Represents a string value.

This field is a member of `oneof`_ ``delta``.
bool_value (bool):
Optional. Represents a boolean value.

This field is a member of `oneof`_ ``delta``.
json_path (str):
Required. A JSON Path (RFC 9535) to the argument being
streamed. https://datatracker.ietf.org/doc/html/rfc9535.
e.g. "$.foo.bar[0].data".
will_continue (bool):
Optional. Whether this is not the last part of the same
json_path. If true, another PartialArg message for the
current json_path is expected to follow.
"""

null_value: struct_pb2.NullValue = proto.Field(
proto.ENUM,
number=2,
oneof="delta",
enum=struct_pb2.NullValue,
)
number_value: float = proto.Field(
proto.DOUBLE,
number=3,
oneof="delta",
)
string_value: str = proto.Field(
proto.STRING,
number=4,
oneof="delta",
)
bool_value: bool = proto.Field(
proto.BOOL,
number=5,
oneof="delta",
)
json_path: str = proto.Field(
proto.STRING,
number=1,
)
will_continue: bool = proto.Field(
proto.BOOL,
number=6,
)


class FunctionResponsePart(proto.Message):
Expand Down Expand Up @@ -991,6 +1079,11 @@ class FunctionCallingConfig(proto.Message):
ANY. Function names should match [FunctionDeclaration.name].
With mode set to ANY, model will predict a function call
from the set of function names provided.
stream_function_call_arguments (bool):
Optional. When set to true, arguments of a single function
call will be streamed out in multiple
parts/contents/responses. Partial parameter results will be
returned in the [FunctionCall.partial_args] field.
"""

class Mode(proto.Enum):
Expand Down Expand Up @@ -1030,6 +1123,10 @@ class Mode(proto.Enum):
proto.STRING,
number=2,
)
stream_function_call_arguments: bool = proto.Field(
proto.BOOL,
number=4,
)


class RetrievalConfig(proto.Message):
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/aiplatform_v1beta1/types/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class Environment(proto.Enum):
)
url_context: "UrlContext" = proto.Field(
proto.MESSAGE,
number=8,
number=10,
message="UrlContext",
)
computer_use: ComputerUse = proto.Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-aiplatform",
"version": "1.129.0"
"version": "0.0.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-aiplatform",
"version": "1.129.0"
"version": "0.0.0"
},
"snippets": [
{
Expand Down
68 changes: 64 additions & 4 deletions tests/unit/gapic/aiplatform_v1/test_gen_ai_cache_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4617,7 +4617,21 @@ def test_create_cached_content_rest_call_success(request_type):
"mime_type": "mime_type_value",
"file_uri": "file_uri_value",
},
"function_call": {"name": "name_value", "args": {"fields": {}}},
"function_call": {
"name": "name_value",
"args": {"fields": {}},
"partial_args": [
{
"null_value": 0,
"number_value": 0.1285,
"string_value": "string_value_value",
"bool_value": True,
"json_path": "json_path_value",
"will_continue": True,
}
],
"will_continue": True,
},
"function_response": {
"name": "name_value",
"response": {},
Expand Down Expand Up @@ -4766,6 +4780,7 @@ def test_create_cached_content_rest_call_success(request_type):
"allowed_function_names_value1",
"allowed_function_names_value2",
],
"stream_function_call_arguments": True,
},
"retrieval_config": {
"lat_lng": {"latitude": 0.86, "longitude": 0.971},
Expand Down Expand Up @@ -5147,7 +5162,21 @@ def test_update_cached_content_rest_call_success(request_type):
"mime_type": "mime_type_value",
"file_uri": "file_uri_value",
},
"function_call": {"name": "name_value", "args": {"fields": {}}},
"function_call": {
"name": "name_value",
"args": {"fields": {}},
"partial_args": [
{
"null_value": 0,
"number_value": 0.1285,
"string_value": "string_value_value",
"bool_value": True,
"json_path": "json_path_value",
"will_continue": True,
}
],
"will_continue": True,
},
"function_response": {
"name": "name_value",
"response": {},
Expand Down Expand Up @@ -5296,6 +5325,7 @@ def test_update_cached_content_rest_call_success(request_type):
"allowed_function_names_value1",
"allowed_function_names_value2",
],
"stream_function_call_arguments": True,
},
"retrieval_config": {
"lat_lng": {"latitude": 0.86, "longitude": 0.971},
Expand Down Expand Up @@ -6539,7 +6569,21 @@ async def test_create_cached_content_rest_asyncio_call_success(request_type):
"mime_type": "mime_type_value",
"file_uri": "file_uri_value",
},
"function_call": {"name": "name_value", "args": {"fields": {}}},
"function_call": {
"name": "name_value",
"args": {"fields": {}},
"partial_args": [
{
"null_value": 0,
"number_value": 0.1285,
"string_value": "string_value_value",
"bool_value": True,
"json_path": "json_path_value",
"will_continue": True,
}
],
"will_continue": True,
},
"function_response": {
"name": "name_value",
"response": {},
Expand Down Expand Up @@ -6688,6 +6732,7 @@ async def test_create_cached_content_rest_asyncio_call_success(request_type):
"allowed_function_names_value1",
"allowed_function_names_value2",
],
"stream_function_call_arguments": True,
},
"retrieval_config": {
"lat_lng": {"latitude": 0.86, "longitude": 0.971},
Expand Down Expand Up @@ -7105,7 +7150,21 @@ async def test_update_cached_content_rest_asyncio_call_success(request_type):
"mime_type": "mime_type_value",
"file_uri": "file_uri_value",
},
"function_call": {"name": "name_value", "args": {"fields": {}}},
"function_call": {
"name": "name_value",
"args": {"fields": {}},
"partial_args": [
{
"null_value": 0,
"number_value": 0.1285,
"string_value": "string_value_value",
"bool_value": True,
"json_path": "json_path_value",
"will_continue": True,
}
],
"will_continue": True,
},
"function_response": {
"name": "name_value",
"response": {},
Expand Down Expand Up @@ -7254,6 +7313,7 @@ async def test_update_cached_content_rest_asyncio_call_success(request_type):
"allowed_function_names_value1",
"allowed_function_names_value2",
],
"stream_function_call_arguments": True,
},
"retrieval_config": {
"lat_lng": {"latitude": 0.86, "longitude": 0.971},
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/gapic/aiplatform_v1/test_gen_ai_tuning_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4617,6 +4617,17 @@ def test_create_tuning_job_rest_call_success(request_type):
"function_call": {
"name": "name_value",
"args": {"fields": {}},
"partial_args": [
{
"null_value": 0,
"number_value": 0.1285,
"string_value": "string_value_value",
"bool_value": True,
"json_path": "json_path_value",
"will_continue": True,
}
],
"will_continue": True,
},
"function_response": {
"name": "name_value",
Expand Down Expand Up @@ -6237,6 +6248,17 @@ async def test_create_tuning_job_rest_asyncio_call_success(request_type):
"function_call": {
"name": "name_value",
"args": {"fields": {}},
"partial_args": [
{
"null_value": 0,
"number_value": 0.1285,
"string_value": "string_value_value",
"bool_value": True,
"json_path": "json_path_value",
"will_continue": True,
}
],
"will_continue": True,
},
"function_response": {
"name": "name_value",
Expand Down