Run in interactive mode for manual testing.
()
| 361 | |
| 362 | |
| 363 | async def interactive_mode(): |
| 364 | """Run in interactive mode for manual testing.""" |
| 365 | # Check if interactions API is available |
| 366 | if not check_interactions_api_available(): |
| 367 | print("\nERROR: Interactions API is not available in the current SDK.") |
| 368 | print("To use the interactions API, ensure you have the SDK with") |
| 369 | print("interactions support installed (e.g., from private-python-genai).") |
| 370 | return |
| 371 | |
| 372 | print("\nInteractive mode with Interactions API") |
| 373 | print("Type 'quit' to exit, 'new' for a new session\n") |
| 374 | |
| 375 | test_agent = agent.root_agent |
| 376 | |
| 377 | runner = InMemoryRunner( |
| 378 | agent=test_agent, |
| 379 | app_name=APP_NAME, |
| 380 | ) |
| 381 | |
| 382 | session = await runner.session_service.create_session( |
| 383 | user_id=USER_ID, |
| 384 | app_name=APP_NAME, |
| 385 | ) |
| 386 | print(f"Session created: {session.id}\n") |
| 387 | |
| 388 | while True: |
| 389 | try: |
| 390 | user_input = input("You: ").strip() |
| 391 | if not user_input: |
| 392 | continue |
| 393 | if user_input.lower() == "quit": |
| 394 | break |
| 395 | if user_input.lower() == "new": |
| 396 | session = await runner.session_service.create_session( |
| 397 | user_id=USER_ID, |
| 398 | app_name=APP_NAME, |
| 399 | ) |
| 400 | print(f"New session created: {session.id}\n") |
| 401 | continue |
| 402 | |
| 403 | await call_agent_async(runner, USER_ID, session.id, user_input) |
| 404 | |
| 405 | except KeyboardInterrupt: |
| 406 | break |
| 407 | |
| 408 | print("\nGoodbye!") |
| 409 | |
| 410 | |
| 411 | def main(): |
no test coverage detected