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
14 changes: 13 additions & 1 deletion vertexai/_genai/agent_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ def create(
agent_framework=config.agent_framework,
python_version=config.python_version,
build_options=config.build_options,
image_spec=config.image_spec,
)
operation = self._create(config=api_config)
reasoning_engine_id = _agent_engines_utils._get_reasoning_engine_id(
Expand Down Expand Up @@ -1012,6 +1013,9 @@ def _set_source_code_spec(
requirements_file: Optional[str] = None,
sys_version: str,
build_options: Optional[dict[str, list[str]]] = None,
image_spec: Optional[
types.ReasoningEngineSpecSourceCodeSpecImageSpecDict
] = None,
) -> None:
"""Sets source_code_spec for agent engine inside the `spec`."""
source_code_spec = types.ReasoningEngineSpecSourceCodeSpecDict()
Expand All @@ -1035,7 +1039,11 @@ def _set_source_code_spec(
raise ValueError(
"Please specify one of `source_packages` or `developer_connect_source`."
)

if image_spec is not None:
update_masks.append("spec.source_code_spec.image_spec")
source_code_spec["image_spec"] = image_spec
spec["source_code_spec"] = source_code_spec
return
update_masks.append("spec.source_code_spec.python_spec.version")
python_spec: types.ReasoningEngineSpecSourceCodeSpecPythonSpecDict = {
"version": sys_version,
Expand Down Expand Up @@ -1200,6 +1208,9 @@ def _create_config(
agent_framework: Optional[str] = None,
python_version: Optional[str] = None,
build_options: Optional[dict[str, list[str]]] = None,
image_spec: Optional[
types.ReasoningEngineSpecSourceCodeSpecImageSpecDict
] = None,
) -> types.UpdateAgentEngineConfigDict:
import sys

Expand Down Expand Up @@ -1285,6 +1296,7 @@ def _create_config(
requirements_file=requirements_file,
sys_version=sys_version,
build_options=build_options,
image_spec=image_spec,
)

if agent_engine_spec is not None:
Expand Down
6 changes: 6 additions & 0 deletions vertexai/_genai/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,9 @@
from .common import ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceDict
from .common import ReasoningEngineSpecSourceCodeSpecDeveloperConnectSourceOrDict
from .common import ReasoningEngineSpecSourceCodeSpecDict
from .common import ReasoningEngineSpecSourceCodeSpecImageSpec
from .common import ReasoningEngineSpecSourceCodeSpecImageSpecDict
from .common import ReasoningEngineSpecSourceCodeSpecImageSpecOrDict
from .common import ReasoningEngineSpecSourceCodeSpecInlineSource
from .common import ReasoningEngineSpecSourceCodeSpecInlineSourceDict
from .common import ReasoningEngineSpecSourceCodeSpecInlineSourceOrDict
Expand Down Expand Up @@ -1416,6 +1419,9 @@
"ReasoningEngineSpecSourceCodeSpecPythonSpec",
"ReasoningEngineSpecSourceCodeSpecPythonSpecDict",
"ReasoningEngineSpecSourceCodeSpecPythonSpecOrDict",
"ReasoningEngineSpecSourceCodeSpecImageSpec",
"ReasoningEngineSpecSourceCodeSpecImageSpecDict",
"ReasoningEngineSpecSourceCodeSpecImageSpecOrDict",
"ReasoningEngineSpecSourceCodeSpec",
"ReasoningEngineSpecSourceCodeSpecDict",
"ReasoningEngineSpecSourceCodeSpecOrDict",
Expand Down
41 changes: 41 additions & 0 deletions vertexai/_genai/types/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5118,6 +5118,34 @@ class ReasoningEngineSpecSourceCodeSpecPythonSpecDict(TypedDict, total=False):
]


class ReasoningEngineSpecSourceCodeSpecImageSpec(_common.BaseModel):
"""The image spec for building an image (within a single build step).

It is based on the config file (i.e. Dockerfile) in the source directory.
"""

build_args: Optional[dict[str, str]] = Field(
default=None,
description="""Optional. Build arguments to be used. They will be passed through --build-arg flags.""",
)


class ReasoningEngineSpecSourceCodeSpecImageSpecDict(TypedDict, total=False):
"""The image spec for building an image (within a single build step).

It is based on the config file (i.e. Dockerfile) in the source directory.
"""

build_args: Optional[dict[str, str]]
"""Optional. Build arguments to be used. They will be passed through --build-arg flags."""


ReasoningEngineSpecSourceCodeSpecImageSpecOrDict = Union[
ReasoningEngineSpecSourceCodeSpecImageSpec,
ReasoningEngineSpecSourceCodeSpecImageSpecDict,
]


class ReasoningEngineSpecSourceCodeSpec(_common.BaseModel):
"""Specification for deploying from source code."""

Expand All @@ -5133,6 +5161,10 @@ class ReasoningEngineSpecSourceCodeSpec(_common.BaseModel):
python_spec: Optional[ReasoningEngineSpecSourceCodeSpecPythonSpec] = Field(
default=None, description="""Configuration for a Python application."""
)
image_spec: Optional[ReasoningEngineSpecSourceCodeSpecImageSpec] = Field(
default=None,
description="""Optional. Configuration for building an image with custom config file.""",
)


class ReasoningEngineSpecSourceCodeSpecDict(TypedDict, total=False):
Expand All @@ -5149,6 +5181,9 @@ class ReasoningEngineSpecSourceCodeSpecDict(TypedDict, total=False):
python_spec: Optional[ReasoningEngineSpecSourceCodeSpecPythonSpecDict]
"""Configuration for a Python application."""

image_spec: Optional[ReasoningEngineSpecSourceCodeSpecImageSpecDict]
"""Optional. Configuration for building an image with custom config file."""


ReasoningEngineSpecSourceCodeSpecOrDict = Union[
ReasoningEngineSpecSourceCodeSpec, ReasoningEngineSpecSourceCodeSpecDict
Expand Down Expand Up @@ -14004,6 +14039,9 @@ class AgentEngineConfig(_common.BaseModel):
subdirectory and the path must be added to `extra_packages`.
""",
)
image_spec: Optional[ReasoningEngineSpecSourceCodeSpecImageSpec] = Field(
default=None, description="""The image spec for the Agent Engine."""
)


class AgentEngineConfigDict(TypedDict, total=False):
Expand Down Expand Up @@ -14167,6 +14205,9 @@ class AgentEngineConfigDict(TypedDict, total=False):
subdirectory and the path must be added to `extra_packages`.
"""

image_spec: Optional[ReasoningEngineSpecSourceCodeSpecImageSpecDict]
"""The image spec for the Agent Engine."""


AgentEngineConfigOrDict = Union[AgentEngineConfig, AgentEngineConfigDict]

Expand Down
Loading