docs(adk): align quickstart script with other orchestrations

This brings the ADK Python quickstart sample up to par with the other orchestrations (like Langchain), removing the need for special test handling.
This commit is contained in:
Anubhav Dhawan
2026-02-05 18:45:19 +05:30
parent 80ef346214
commit c702b2ac2b
2 changed files with 41 additions and 16 deletions

View File

@@ -1,6 +1,27 @@
import asyncio
from google.adk import Agent
from google.adk.apps import App
from google.adk.runners import InMemoryRunner
from google.adk.tools.toolbox_toolset import ToolboxToolset
from google.genai.types import Content, Part
prompt = """
You're a helpful hotel assistant. You handle hotel searching, booking and
cancellations. When the user searches for a hotel, mention it's name, id,
location and price tier. Always mention hotel ids while performing any
searches. This is very important for any operations. For any bookings or
cancellations, please provide the appropriate confirmation. Be sure to
update checkin or checkout dates if mentioned by the user.
Don't ask for confirmations from the user.
"""
queries = [
"Find hotels in Basel with Basel in its name.",
"Can you book the Hilton Basel for me?",
"Oh wait, this is too expensive. Please cancel it and book the Hyatt Regency instead.",
"My check in dates would be from April 10, 2024 to April 19, 2024.",
]
# TODO(developer): update the TOOLBOX_URL to your toolbox endpoint
toolset = ToolboxToolset(
@@ -8,10 +29,27 @@ toolset = ToolboxToolset(
)
root_agent = Agent(
name='root_agent',
name='hotel_assistant',
model='gemini-2.5-flash',
instruction="You are a helpful AI assistant designed to provide accurate and useful information.",
instruction=prompt,
tools=[toolset],
)
app = App(root_agent=root_agent, name="my_agent")
async def main():
runner = InMemoryRunner(agent=root_agent, app=app)
session = await runner.session_service.create_session(
app_name=app.name, user_id="test_user"
)
for query in queries:
print(f"\nUser: {query}")
user_message = Content(parts=[Part.from_text(text=query)])
async for event in runner.run_async(session_id=session.id, new_message=user_message):
if event.is_final_response():
print(f"Agent: {event.content.parts[0].text}")
if __name__ == "__main__":
asyncio.run(main())