Package agent_engines (1.118.0)

API documentation for agent_engines package.

Classes

AG2Agent

An AG2 Agent.

AdkApp

An ADK Application.

AgentEngine

Represents a Vertex AI Agent Engine resource.

AsyncQueryable

Protocol for Agent Engines that can be queried asynchronously.

AsyncStreamQueryable

Protocol for Agent Engines that can stream responses asynchronously.

Cloneable

Protocol for Agent Engines that can be cloned.

LangchainAgent

A Langchain Agent.

See https://cloud.google.com/vertex-ai/generative-ai/docs/reasoning-engine/develop for details.

LanggraphAgent

A LangGraph Agent.

ModuleAgent

Agent that is defined by a module and an agent name.

This agent is instantiated by importing a module and instantiating an agent from that module. It also allows to register operations that are defined in the agent.

OperationRegistrable

Protocol for agents that have registered operations.

Queryable

Protocol for Agent Engines that can be queried.

StreamQueryable

Protocol for Agent Engines that can stream responses.

Packages Functions

create

create(
    agent_engine: typing.Union[
        None,
        vertexai.agent_engines.AsyncQueryable,
        vertexai.agent_engines.AsyncStreamQueryable,
        vertexai.agent_engines._agent_engines.BidiStreamQueryable,
        vertexai.agent_engines.OperationRegistrable,
        vertexai.agent_engines.Queryable,
        vertexai.agent_engines.StreamQueryable,
    ] = None,
    *,
    requirements: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
    display_name: typing.Optional[str] = None,
    description: typing.Optional[str] = None,
    gcs_dir_name: typing.Optional[str] = None,
    extra_packages: typing.Optional[typing.Sequence[str]] = None,
    env_vars: typing.Optional[
        typing.Union[
            typing.Sequence[str],
            typing.Dict[
                str,
                typing.Union[str, google.cloud.aiplatform_v1.types.env_var.SecretRef],
            ],
        ]
    ] = None,
    build_options: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None,
    service_account: typing.Optional[str] = None,
    psc_interface_config: typing.Optional[
        google.cloud.aiplatform_v1.types.service_networking.PscInterfaceConfig
    ] = None,
    min_instances: typing.Optional[int] = None,
    max_instances: typing.Optional[int] = None,
    resource_limits: typing.Optional[typing.Dict[str, str]] = None,
    container_concurrency: typing.Optional[int] = None,
    encryption_spec: typing.Optional[
        google.cloud.aiplatform_v1.types.encryption_spec.EncryptionSpec
    ] = None
) -> vertexai.agent_engines.AgentEngine

Creates a new Agent Engine.

The Agent Engine will be an instance of the agent_engine that was passed in, running remotely on Vertex AI.

Sample src_dir contents (e.g. ./user_src_dir):

user_src_dir/
|-- main.py
|-- requirements.txt
|-- user_code/
|   |-- utils.py
|   |-- ...
|-- installation_scripts/
|   |-- install_package.sh
|   |-- ...
|-- ...

To build an Agent Engine with the above files, run:

remote_agent = agent_engines.create(
    agent_engine=local_agent,
    requirements=[
        # I.e. the PyPI dependencies listed in requirements.txt
        "google-cloud-aiplatform==1.25.0",
        "langchain==0.0.242",
        ...
    ],
    extra_packages=[
        "./user_src_dir/main.py", # a single file
        "./user_src_dir/user_code", # a directory
        ...
    ],
    build_options={
        "installation": [
            "./user_src_dir/installation_scripts/install_package.sh",
            ...
        ],
    },
)
Parameters
Name Description
agent_engine AgentEngineInterface

Required. The Agent Engine to be created.

requirements Union[str, Sequence[str]]

Optional. The set of PyPI dependencies needed. It can either be the path to a single file (requirements.txt), or an ordered list of strings corresponding to each line of the requirements file.

display_name str

Optional. The user-defined name of the Agent Engine. The name can be up to 128 characters long and can comprise any UTF-8 character.

description str

Optional. The description of the Agent Engine.

gcs_dir_name str

Optional. The GCS bucket directory under staging_bucket to use for staging the artifacts needed.

extra_packages Sequence[str]

Optional. The set of extra user-provided packages (if any).

env_vars Union[Sequence[str], Dict[str, Union[str, SecretRef]]]

Optional. The environment variables to be set when running the Agent Engine. If it is a list of strings, each string should be a valid key to os.environ. If it is a dictionary, the keys are the environment variable names, and the values are the corresponding values.

build_options Dict[str, Sequence[str]]

Optional. The build options for the Agent Engine. This includes options such as installation scripts.

service_account str

Optional. The service account to be used for the Agent Engine. If not specified, the default reasoning engine service agent service account will be used.

psc_interface_config PscInterfaceConfig

Optional. The PSC interface config for the Agent Engine. If not specified, the default PSC interface config will be used.

min_instances int

Optional. The minimum number of instances to run the Agent Engine. If not specified, the default value will be used.

max_instances int

Optional. The maximum number of instances to run the Agent Engine. If not specified, the default value will be used.

resource_limits Dict[str, str]

Optional. The resource limits for the Agent Engine. If not specified, the default value will be used.

container_concurrency int

Optional. The container concurrency for the Agent Engine. If not specified, the default value will be used.

encryption_spec EncryptionSpec

Optional. The encryption spec for the Agent Engine. If not specified, the default encryption spec will be used.

delete

delete(resource_name: str, *, force: bool = False, **kwargs) -> None

Delete an Agent Engine resource.

Parameters
Name Description
resource_name str

Required. The name of the Agent Engine to be deleted. Format: projects/{project}/locations/{location}/reasoningEngines/{resource_id}

force bool

Optional. If set to True, child resources will also be deleted. Otherwise, the request will fail with FAILED_PRECONDITION error when the Agent Engine has undeleted child resources. Defaults to False.

\*\*kwargs dict[str, Any]

Optional. Additional keyword arguments to pass to the delete_reasoning_engine method.

get

get(resource_name: str) -> vertexai.agent_engines.AgentEngine

Retrieves an Agent Engine resource.

Parameter
Name Description
resource_name str

Required. A fully-qualified resource name or ID such as "projects/123/locations/us-central1/reasoningEngines/456" or "456" when project and location are initialized or passed.

list

list(*, filter: str = "") -> typing.Iterable[vertexai.agent_engines.AgentEngine]

List all instances of Agent Engine matching the filter.

Example Usage:

    import vertexai
    from vertexai import agent_engines
<xref uid="vertexai.init">vertexai.init</xref>(project="my_project", location="us-central1")
agent_engines.list(filter='display_name="My Custom Agent"')
Parameter
Name Description
filter str

Optional. An expression for filtering the results of the request. For field names both snake_case and camelCase are supported.

update

update(
    resource_name: str,
    *,
    agent_engine: typing.Optional[
        typing.Union[
            vertexai.agent_engines.Queryable,
            vertexai.agent_engines.OperationRegistrable,
        ]
    ] = None,
    requirements: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
    display_name: typing.Optional[str] = None,
    description: typing.Optional[str] = None,
    gcs_dir_name: typing.Optional[str] = None,
    extra_packages: typing.Optional[typing.Sequence[str]] = None,
    env_vars: typing.Optional[
        typing.Union[
            typing.Sequence[str],
            typing.Dict[
                str,
                typing.Union[str, google.cloud.aiplatform_v1.types.env_var.SecretRef],
            ],
        ]
    ] = None,
    build_options: typing.Optional[typing.Dict[str, typing.Sequence[str]]] = None,
    service_account: typing.Optional[str] = None,
    psc_interface_config: typing.Optional[
        google.cloud.aiplatform_v1.types.service_networking.PscInterfaceConfig
    ] = None,
    min_instances: typing.Optional[int] = None,
    max_instances: typing.Optional[int] = None,
    resource_limits: typing.Optional[typing.Dict[str, str]] = None,
    container_concurrency: typing.Optional[int] = None,
    encryption_spec: typing.Optional[
        google.cloud.aiplatform_v1.types.encryption_spec.EncryptionSpec
    ] = None
) -> vertexai.agent_engines.AgentEngine

Updates an existing Agent Engine.

This method updates the configuration of a deployed Agent Engine, identified by its resource name. Unlike the create function which requires an agent_engine object, all arguments in this method are optional. This method allows you to modify individual aspects of the configuration by providing any of the optional arguments.

Parameters
Name Description
resource_name str

Required. The name of the Agent Engine to be updated. Format: projects/{project}/locations/{location}/reasoningEngines/{resource_id}.

agent_engine AgentEngineInterface

Optional. The instance to be used as the updated Agent Engine. If it is not specified, the existing instance will be used.

requirements Union[str, Sequence[str]]

Optional. The set of PyPI dependencies needed. It can either be the path to a single file (requirements.txt), or an ordered list of strings corresponding to each line of the requirements file. If it is not specified, the existing requirements will be used. If it is set to an empty string or list, the existing requirements will be removed.

display_name str

Optional. The user-defined name of the Agent Engine. The name can be up to 128 characters long and can comprise any UTF-8 character.

description str

Optional. The description of the Agent Engine.

gcs_dir_name str

Optional. The GCS bucket directory under staging_bucket to use for staging the artifacts needed.

extra_packages Sequence[str]

Optional. The set of extra user-provided packages (if any). If it is not specified, the existing extra packages will be used. If it is set to an empty list, the existing extra packages will be removed.

env_vars Union[Sequence[str], Dict[str, Union[str, SecretRef]]]

Optional. The environment variables to be set when running the Agent Engine. If it is a list of strings, each string should be a valid key to os.environ. If it is a dictionary, the keys are the environment variable names, and the values are the corresponding values.

build_options Dict[str, Sequence[str]]

Optional. The build options for the Agent Engine. This includes options such as installation scripts.

service_account str

Optional. The service account to be used for the Agent Engine. If not specified, the default reasoning engine service agent service account will be used.

min_instances int

Optional. The minimum number of instances to run the Agent Engine. If not specified, the default value will be used.

max_instances int

Optional. The maximum number of instances to run the Agent Engine. If not specified, the default value will be used.

resource_limits Dict[str, str]

Optional. The resource limits for the Agent Engine. If not specified, the default value will be used.

container_concurrency int

Optional. The container concurrency for the Agent Engine. If not specified, the default value will be used.

encryption_spec EncryptionSpec

Optional. The encryption spec for the Agent Engine. If not specified, the default encryption spec will be used.