@@ -97,6 +97,79 @@ Then run evaluation by providing the inference results and specifying the metric
9797 ]
9898 )
9999
100+ Agent Engine with Agent Development Kit (ADK)
101+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
102+
103+ First, define a function that looks up the exchange rate:
104+
105+ .. code-block :: Python
106+
107+ def get_exchange_rate (
108+ currency_from : str = " USD" ,
109+ currency_to : str = " EUR" ,
110+ currency_date : str = " latest" ,
111+ ):
112+ """ Retrieves the exchange rate between two currencies on a specified date.
113+
114+ Uses the Frankfurter API (https://api.frankfurter.app/) to obtain
115+ exchange rate data.
116+
117+ Returns:
118+ dict: A dictionary containing the exchange rate information.
119+ Example: {"amount": 1.0, "base": "USD", "date": "2023-11-24",
120+ "rates": {"EUR": 0.95534}}
121+ """
122+ import requests
123+ response = requests.get(
124+ f " https://api.frankfurter.app/ { currency_date} " ,
125+ params = {" from" : currency_from, " to" : currency_to},
126+ )
127+ return response.json()
128+
129+ Next, define an ADK Agent:
130+
131+ .. code-block :: Python
132+
133+ from google.adk.agents import Agent
134+ from vertexai.agent_engines import AdkApp
135+
136+ app = AdkApp(agent = Agent(
137+ model = " gemini-2.0-flash" , # Required.
138+ name = ' currency_exchange_agent' , # Required.
139+ tools = [get_exchange_rate], # Optional.
140+ ))
141+
142+ Test the agent locally using US dollars and Swedish Krona:
143+
144+ .. code-block :: Python
145+
146+ async for event in app.async_stream_query(
147+ user_id = " user-id" ,
148+ message = " What is the exchange rate from US dollars to SEK today?" ,
149+ ):
150+ print (event)
151+
152+ To deploy the agent to Agent Engine:
153+
154+ .. code-block :: Python
155+
156+ remote_app = client.agent_engines.create(
157+ agent = app,
158+ config = {
159+ " requirements" : [" google-cloud-aiplatform[agent_engines,adk]" ],
160+ },
161+ )
162+
163+ You can also run queries against the deployed agent:
164+
165+ .. code-block :: Python
166+
167+ async for event in remote_app.async_stream_query(
168+ user_id = " user-id" ,
169+ message = " What is the exchange rate from US dollars to SEK today?" ,
170+ ):
171+ print (event)
172+
100173 Prompt optimization
101174^^^^^^^^^^^^^^^^^^^
102175
0 commit comments