MCPcopy Index your code
hub / github.com/google/adk-python / main

Function main

contributing/samples/integrations/sandbox_computer_use/main.py:85–161  ·  view source on GitHub ↗

Main function to run the sandbox computer use agent.

()

Source from the content-addressed store, hash-verified

83
84
85async def main():
86 """Main function to run the sandbox computer use agent."""
87 # Validate environment
88 project_id = os.environ.get("GOOGLE_CLOUD_PROJECT")
89 service_account = os.environ.get("VMAAS_SERVICE_ACCOUNT")
90
91 if not project_id:
92 print("ERROR: GOOGLE_CLOUD_PROJECT environment variable is not set.")
93 print("Please set it to your GCP project ID.")
94 return
95
96 if not service_account:
97 print("ERROR: VMAAS_SERVICE_ACCOUNT environment variable is not set.")
98 print(
99 "Please set it to your service account email with"
100 " roles/iam.serviceAccountTokenCreator permission."
101 )
102 return
103
104 print("=" * 60)
105 print("Sandbox Computer Use Agent Demo")
106 print("=" * 60)
107 print(f"Project: {project_id}")
108 print(f"Service Account: {service_account}")
109 print("=" * 60)
110
111 app_name = "sandbox_computer_use_demo"
112 user_id = "demo_user"
113
114 # Create runner and session
115 runner = InMemoryRunner(
116 agent=agent.root_agent,
117 app_name=app_name,
118 )
119 session = await runner.session_service.create_session(
120 app_name=app_name, user_id=user_id
121 )
122
123 print(f"\nSession created: {session.id}")
124 print("\nStarting agent interaction...")
125
126 start_time = time.time()
127
128 # Example interaction: Navigate and describe
129 await run_prompt(
130 runner,
131 session,
132 user_id,
133 "Navigate to https://www.google.com and tell me what you see.",
134 )
135
136 # Example interaction: Search for something
137 await run_prompt(
138 runner,
139 session,
140 user_id,
141 "Search for 'Vertex AI Agent Engine' and tell me the first result.",
142 )

Callers 1

main.pyFile · 0.70

Calls 7

InMemoryRunnerClass · 0.90
timeMethod · 0.80
run_promptFunction · 0.70
getMethod · 0.45
create_sessionMethod · 0.45
get_sessionMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected