에이전트 개발 키트로 Agent Runtime에서 에이전트 개발 및 배포
Agent Runtime을 사용하면 에이전트 개발 키트 (ADK)로 개발된 에이전트를 호스팅할 수 있습니다. 이 문서에서는 ADK를 사용하여 에이전트를 만들고 배포하고 테스트하는 방법을 설명합니다.
이 빠른 시작에서는 다음 단계를 안내합니다.
- 프로젝트를 설정합니다. Google Cloud
- Python용 Agent Platform SDK 및 ADK를 설치합니다.
- 환전 에이전트를 개발합니다.
- 에이전트를 Agent Runtime에 배포합니다.
- 배포된 에이전트를 테스트합니다.
다음과 같은 ADK의 대체 빠른 시작을 사용할 수도 있습니다.
- ADK 빠른 시작: ADK 빠른 시작은 전적으로 머신에서 실행되며 로컬 IDE 및 터미널 액세스를 사용한다고 가정합니다.
- 에이전트 스타터 팩: Agent Platform을 위해 빌드된 프로덕션에 즉시 사용 가능한 생성형 AI 에이전트 템플릿 모음입니다.
에이전트 개발 키트 이외의 지원되는 프레임워크를 사용하는 빠른 시작은 Agent Runtime에서 에이전트 개발 및 배1를 참조하세요.
시작하기 전에
- 계정에 로그인합니다. Google Cloud 를 처음 사용하는 경우 Google Cloud, 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 신규 고객에게는 워크로드를 실행, 테스트, 배포하는 데 사용할 수 있는 $300의 무료 크레딧이 제공됩니다.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Agent Platform and Cloud Storage APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Agent Platform and Cloud Storage APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.
Agent Runtime을 사용하는 데 필요한 권한을 얻으려면 관리자에게 프로젝트에 대한 다음 IAM 역할을 부여해 달라고 요청하세요.
- Agent Platform 사용자 (
roles/aiplatform.user) - 스토리지 관리자 (
roles/storage.admin)
역할 부여에 대한 자세한 내용은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.
Python용 Agent Platform SDK 설치 및 초기화
다음 명령어를 실행하여 Python용 Agent Platform SDK 및 기타 필수 패키지를 설치합니다.
pip install --upgrade --quiet google-cloud-aiplatform[agent_engines,adk]>=1.112사용자로 인증
로컬 셸
다음 명령어를 실행합니다.
gcloud auth application-default loginColab
다음 코드를 실행합니다.
from google.colab import auth auth.authenticate_user(project_id="PROJECT_ID")Cloud Shell
어떤 조치도 필요하지 않습니다.
다음 코드를 실행하여 Agent Platform을 가져오고 SDK를 초기화합니다.
Google Cloud 프로젝트
import vertexai client = vertexai.Client( project="PROJECT_ID", # Your project ID. location="LOCATION", # Your cloud region. )각 항목의 의미는 다음과 같습니다.
PROJECT_ID: 에이전트를 개발하고 배포하는 프로젝트 ID입니다. Google CloudLOCATION은(는) 지원되는 리전 중 하나입니다.
에이전트 개발
에이전트의 환전 도구를 개발합니다.
def get_exchange_rate( currency_from: str = "USD", currency_to: str = "EUR", currency_date: str = "latest", ): """Retrieves the exchange rate between two currencies on a specified date.""" import requests response = requests.get( f"https://api.frankfurter.app/{currency_date}", params={"from": currency_from, "to": currency_to}, ) return response.json()에이전트를 인스턴스화합니다.
from google.adk.agents import Agent from vertexai import agent_engines agent = Agent( model="gemini-2.0-flash", name='currency_exchange_agent', tools=[get_exchange_rate], ) app = agent_engines.AdkApp(agent=agent)에이전트를 로컬에서 테스트합니다.
async for event in app.async_stream_query( user_id="USER_ID", message="What is the exchange rate from US dollars to SEK today?", ): print(event)여기서 USER_ID는 사용자 정의 ID이며 128자(영문 기준)로 제한됩니다.
에이전트 배포
Agent Platform에서 reasoningEngine 리소스를 만들어 에이전트를 배포합니다.
remote_agent = client.agent_engines.create(
agent=app,
config={
"requirements": ["google-cloud-aiplatform[agent_engines,adk]"],
"staging_bucket": "STAGING_BUCKET",
"identity_type": types.IdentityType.AGENT_IDENTITY,
}
)
여기서 STAGING_BUCKET은 gs://로 시작하는 Cloud Storage 버킷입니다.
에이전트 사용
쿼리를 전송하여 배포된 에이전트를 테스트합니다.
async for event in remote_agent.async_stream_query(
user_id="USER_ID",
message="What is the exchange rate from US dollars to SEK today?",
):
print(event)
정리
이 페이지에서 사용한 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 다음 단계를 수행합니다.
remote_agent.delete(force=True)