Skip to content

Commit b8e4aed

Browse files
yeesiancopybara-github
authored andcommitted
fix: Add vertexai initialization for code being deployed to AgentEngine
Co-authored-by: Yeesian Ng <ysian@google.com> PiperOrigin-RevId: 832031219
1 parent ffbb0b3 commit b8e4aed

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/google/adk/cli/cli_deploy.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
"""
6565

6666
_AGENT_ENGINE_APP_TEMPLATE: Final[str] = """
67+
import os
68+
import vertexai
6769
from vertexai.agent_engines import AdkApp
6870
6971
if {is_config_agent}:
@@ -78,9 +80,12 @@
7880
from .agent import {adk_app_object}
7981
8082
if {express_mode}: # Whether or not to use Express Mode
81-
import os
82-
import vertexai
8383
vertexai.init(api_key=os.environ.get("GOOGLE_API_KEY"))
84+
else:
85+
vertexai.init(
86+
project=os.environ.get("GOOGLE_CLOUD_PROJECT"),
87+
location=os.environ.get("GOOGLE_CLOUD_LOCATION"),
88+
)
8489
8590
adk_app = AdkApp(
8691
{adk_app_type}={adk_app_object},

0 commit comments

Comments
 (0)