You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Add enable_a2a option to adk command line
PiperOrigin-RevId: 775991652
This commit is contained in:
committed by
Copybara-Service
parent
630f1674cb
commit
ed09cd840f
@@ -55,7 +55,7 @@ COPY "agents/{app_name}/" "/app/agents/{app_name}/"
|
||||
|
||||
EXPOSE {port}
|
||||
|
||||
CMD adk {command} --port={port} {host_option} {service_option} {trace_to_cloud_option} {allow_origins_option} "/app/agents"
|
||||
CMD adk {command} --port={port} {host_option} {service_option} {trace_to_cloud_option} {allow_origins_option} {a2a_option}"/app/agents"
|
||||
"""
|
||||
|
||||
_AGENT_ENGINE_APP_TEMPLATE = """
|
||||
@@ -128,6 +128,7 @@ def to_cloud_run(
|
||||
session_service_uri: Optional[str] = None,
|
||||
artifact_service_uri: Optional[str] = None,
|
||||
memory_service_uri: Optional[str] = None,
|
||||
a2a: bool = False,
|
||||
):
|
||||
"""Deploys an agent to Google Cloud Run.
|
||||
|
||||
@@ -189,6 +190,7 @@ def to_cloud_run(
|
||||
allow_origins_option = (
|
||||
f'--allow_origins={",".join(allow_origins)}' if allow_origins else ''
|
||||
)
|
||||
a2a_option = '--a2a' if a2a else ''
|
||||
dockerfile_content = _DOCKERFILE_TEMPLATE.format(
|
||||
gcp_project_id=project,
|
||||
gcp_region=region,
|
||||
@@ -206,6 +208,7 @@ def to_cloud_run(
|
||||
allow_origins_option=allow_origins_option,
|
||||
adk_version=adk_version,
|
||||
host_option=host_option,
|
||||
a2a_option=a2a_option,
|
||||
)
|
||||
dockerfile_path = os.path.join(temp_folder, 'Dockerfile')
|
||||
os.makedirs(temp_folder, exist_ok=True)
|
||||
|
||||
@@ -576,6 +576,13 @@ def fast_api_common_options():
|
||||
" for Cloud Run."
|
||||
),
|
||||
)
|
||||
@click.option(
|
||||
"--a2a",
|
||||
is_flag=True,
|
||||
show_default=True,
|
||||
default=False,
|
||||
help="Optional. Whether to enable A2A endpoint.",
|
||||
)
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
return func(*args, **kwargs)
|
||||
@@ -617,6 +624,7 @@ def cli_web(
|
||||
memory_service_uri: Optional[str] = None,
|
||||
session_db_url: Optional[str] = None, # Deprecated
|
||||
artifact_storage_uri: Optional[str] = None, # Deprecated
|
||||
a2a: bool = False,
|
||||
):
|
||||
"""Starts a FastAPI server with Web UI for agents.
|
||||
|
||||
@@ -663,6 +671,9 @@ def cli_web(
|
||||
web=True,
|
||||
trace_to_cloud=trace_to_cloud,
|
||||
lifespan=_lifespan,
|
||||
a2a=a2a,
|
||||
host=host,
|
||||
port=port,
|
||||
)
|
||||
config = uvicorn.Config(
|
||||
app,
|
||||
@@ -709,6 +720,7 @@ def cli_api_server(
|
||||
memory_service_uri: Optional[str] = None,
|
||||
session_db_url: Optional[str] = None, # Deprecated
|
||||
artifact_storage_uri: Optional[str] = None, # Deprecated
|
||||
a2a: bool = False,
|
||||
):
|
||||
"""Starts a FastAPI server for agents.
|
||||
|
||||
@@ -733,6 +745,9 @@ def cli_api_server(
|
||||
allow_origins=allow_origins,
|
||||
web=False,
|
||||
trace_to_cloud=trace_to_cloud,
|
||||
a2a=a2a,
|
||||
host=host,
|
||||
port=port,
|
||||
),
|
||||
host=host,
|
||||
port=port,
|
||||
@@ -854,6 +869,7 @@ def cli_deploy_cloud_run(
|
||||
eval_storage_uri: Optional[str] = None,
|
||||
session_db_url: Optional[str] = None, # Deprecated
|
||||
artifact_storage_uri: Optional[str] = None, # Deprecated
|
||||
a2a: bool = False,
|
||||
):
|
||||
"""Deploys an agent to Cloud Run.
|
||||
|
||||
@@ -884,6 +900,7 @@ def cli_deploy_cloud_run(
|
||||
session_service_uri=session_service_uri,
|
||||
artifact_service_uri=artifact_service_uri,
|
||||
memory_service_uri=memory_service_uri,
|
||||
a2a=a2a,
|
||||
)
|
||||
except Exception as e:
|
||||
click.secho(f"Deploy failed: {e}", fg="red", err=True)
|
||||
|
||||
@@ -204,6 +204,9 @@ def get_fast_api_app(
|
||||
eval_storage_uri: Optional[str] = None,
|
||||
allow_origins: Optional[list[str]] = None,
|
||||
web: bool,
|
||||
a2a: bool = False,
|
||||
host: str = "127.0.0.1",
|
||||
port: int = 8000,
|
||||
trace_to_cloud: bool = False,
|
||||
lifespan: Optional[Lifespan[FastAPI]] = None,
|
||||
) -> FastAPI:
|
||||
|
||||
Reference in New Issue
Block a user