@@ -417,28 +417,87 @@ async def _collect_eval_results() -> list[EvalCaseResult]:
417
417
print (eval_result .model_dump_json (indent = 2 ))
418
418
419
419
420
- def fast_api_common_options ():
421
- """Decorator to add common fast api options to click commands."""
420
+ def adk_services_options ():
421
+ """Decorator to add ADK services options to click commands."""
422
422
423
423
def decorator (func ):
424
424
@click .option (
425
- "--session_db_url " ,
425
+ "--session_service_uri " ,
426
426
help = (
427
- """Optional. The database URL to store the session.
427
+ """Optional. The URI of the session service .
428
428
- Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
429
429
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
430
- - See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs ."""
430
+ - See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported database URIs ."""
431
431
),
432
432
)
433
433
@click .option (
434
- "--artifact_storage_uri " ,
434
+ "--artifact_service_uri " ,
435
435
type = str ,
436
436
help = (
437
- "Optional. The artifact storage URI to store the artifacts ,"
437
+ "Optional. The URI of the artifact service ,"
438
438
" supported URIs: gs://<bucket name> for GCS artifact service."
439
439
),
440
440
default = None ,
441
441
)
442
+ @click .option (
443
+ "--memory_service_uri" ,
444
+ type = str ,
445
+ help = (
446
+ """Optional. The URI of the memory service.
447
+ - Use 'rag://<rag_corpus_id>' to connect to Vertex AI Rag Memory Service."""
448
+ ),
449
+ default = None ,
450
+ )
451
+ @functools .wraps (func )
452
+ def wrapper (* args , ** kwargs ):
453
+ return func (* args , ** kwargs )
454
+
455
+ return wrapper
456
+
457
+ return decorator
458
+
459
+
460
+ def deprecated_adk_services_options ():
461
+ """Depracated ADK services options."""
462
+
463
+ def warn (alternative_param , ctx , param , value ):
464
+ if value :
465
+ click .echo (
466
+ click .style (
467
+ f"WARNING: Deprecated option { param .name } is used. Please use"
468
+ f" { alternative_param } instead." ,
469
+ fg = "yellow" ,
470
+ ),
471
+ err = True ,
472
+ )
473
+ return value
474
+
475
+ def decorator (func ):
476
+ @click .option (
477
+ "--session_db_url" ,
478
+ help = "Deprecated. Use --session_service_uri instead." ,
479
+ callback = functools .partial (warn , "--session_service_uri" ),
480
+ )
481
+ @click .option (
482
+ "--artifact_storage_uri" ,
483
+ type = str ,
484
+ help = "Deprecated. Use --artifact_service_uri instead." ,
485
+ callback = functools .partial (warn , "--artifact_service_uri" ),
486
+ default = None ,
487
+ )
488
+ @functools .wraps (func )
489
+ def wrapper (* args , ** kwargs ):
490
+ return func (* args , ** kwargs )
491
+
492
+ return wrapper
493
+
494
+ return decorator
495
+
496
+
497
+ def fast_api_common_options ():
498
+ """Decorator to add common fast api options to click commands."""
499
+
500
+ def decorator (func ):
442
501
@click .option (
443
502
"--host" ,
444
503
type = str ,
@@ -489,6 +548,8 @@ def wrapper(*args, **kwargs):
489
548
490
549
@main .command ("web" )
491
550
@fast_api_common_options ()
551
+ @adk_services_options ()
552
+ @deprecated_adk_services_options ()
492
553
@click .argument (
493
554
"agents_dir" ,
494
555
type = click .Path (
@@ -498,14 +559,17 @@ def wrapper(*args, **kwargs):
498
559
)
499
560
def cli_web (
500
561
agents_dir : str ,
501
- session_db_url : str = "" ,
502
- artifact_storage_uri : Optional [str ] = None ,
503
562
log_level : str = "INFO" ,
504
563
allow_origins : Optional [list [str ]] = None ,
505
564
host : str = "127.0.0.1" ,
506
565
port : int = 8000 ,
507
566
trace_to_cloud : bool = False ,
508
567
reload : bool = True ,
568
+ session_service_uri : Optional [str ] = None ,
569
+ artifact_service_uri : Optional [str ] = None ,
570
+ memory_service_uri : Optional [str ] = None ,
571
+ session_db_url : Optional [str ] = None , # Deprecated
572
+ artifact_storage_uri : Optional [str ] = None , # Deprecated
509
573
):
510
574
"""Starts a FastAPI server with Web UI for agents.
511
575
@@ -514,7 +578,7 @@ def cli_web(
514
578
515
579
Example:
516
580
517
- adk web --session_db_url=[db_url ] --port=[port] path/to/agents_dir
581
+ adk web --session_service_uri=[uri ] --port=[port] path/to/agents_dir
518
582
"""
519
583
logs .setup_adk_logger (getattr (logging , log_level .upper ()))
520
584
@@ -540,10 +604,13 @@ async def _lifespan(app: FastAPI):
540
604
fg = "green" ,
541
605
)
542
606
607
+ session_service_uri = session_service_uri or session_db_url
608
+ artifact_service_uri = artifact_service_uri or artifact_storage_uri
543
609
app = get_fast_api_app (
544
610
agents_dir = agents_dir ,
545
- session_db_url = session_db_url ,
546
- artifact_storage_uri = artifact_storage_uri ,
611
+ session_service_uri = session_service_uri ,
612
+ artifact_service_uri = artifact_service_uri ,
613
+ memory_service_uri = memory_service_uri ,
547
614
allow_origins = allow_origins ,
548
615
web = True ,
549
616
trace_to_cloud = trace_to_cloud ,
@@ -571,16 +638,21 @@ async def _lifespan(app: FastAPI):
571
638
default = os .getcwd (),
572
639
)
573
640
@fast_api_common_options ()
641
+ @adk_services_options ()
642
+ @deprecated_adk_services_options ()
574
643
def cli_api_server (
575
644
agents_dir : str ,
576
- session_db_url : str = "" ,
577
- artifact_storage_uri : Optional [str ] = None ,
578
645
log_level : str = "INFO" ,
579
646
allow_origins : Optional [list [str ]] = None ,
580
647
host : str = "127.0.0.1" ,
581
648
port : int = 8000 ,
582
649
trace_to_cloud : bool = False ,
583
650
reload : bool = True ,
651
+ session_service_uri : Optional [str ] = None ,
652
+ artifact_service_uri : Optional [str ] = None ,
653
+ memory_service_uri : Optional [str ] = None ,
654
+ session_db_url : Optional [str ] = None , # Deprecated
655
+ artifact_storage_uri : Optional [str ] = None , # Deprecated
584
656
):
585
657
"""Starts a FastAPI server for agents.
586
658
@@ -589,15 +661,18 @@ def cli_api_server(
589
661
590
662
Example:
591
663
592
- adk api_server --session_db_url=[db_url ] --port=[port] path/to/agents_dir
664
+ adk api_server --session_service_uri=[uri ] --port=[port] path/to/agents_dir
593
665
"""
594
666
logs .setup_adk_logger (getattr (logging , log_level .upper ()))
595
667
668
+ session_service_uri = session_service_uri or session_db_url
669
+ artifact_service_uri = artifact_service_uri or artifact_storage_uri
596
670
config = uvicorn .Config (
597
671
get_fast_api_app (
598
672
agents_dir = agents_dir ,
599
- session_db_url = session_db_url ,
600
- artifact_storage_uri = artifact_storage_uri ,
673
+ session_service_uri = session_service_uri ,
674
+ artifact_service_uri = artifact_service_uri ,
675
+ memory_service_uri = memory_service_uri ,
601
676
allow_origins = allow_origins ,
602
677
web = False ,
603
678
trace_to_cloud = trace_to_cloud ,
@@ -689,27 +764,6 @@ def cli_api_server(
689
764
default = "WARNING" ,
690
765
help = "Optional. Override the default verbosity level." ,
691
766
)
692
- @click .option (
693
- "--session_db_url" ,
694
- help = (
695
- """Optional. The database URL to store the session.
696
-
697
- - Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
698
-
699
- - Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
700
-
701
- - See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
702
- ),
703
- )
704
- @click .option (
705
- "--artifact_storage_uri" ,
706
- type = str ,
707
- help = (
708
- "Optional. The artifact storage URI to store the artifacts, supported"
709
- " URIs: gs://<bucket name> for GCS artifact service."
710
- ),
711
- default = None ,
712
- )
713
767
@click .argument (
714
768
"agent" ,
715
769
type = click .Path (
@@ -726,6 +780,8 @@ def cli_api_server(
726
780
" version in the dev environment)"
727
781
),
728
782
)
783
+ @adk_services_options ()
784
+ @deprecated_adk_services_options ()
729
785
def cli_deploy_cloud_run (
730
786
agent : str ,
731
787
project : Optional [str ],
@@ -737,9 +793,12 @@ def cli_deploy_cloud_run(
737
793
trace_to_cloud : bool ,
738
794
with_ui : bool ,
739
795
verbosity : str ,
740
- session_db_url : str ,
741
- artifact_storage_uri : Optional [str ],
742
796
adk_version : str ,
797
+ session_service_uri : Optional [str ] = None ,
798
+ artifact_service_uri : Optional [str ] = None ,
799
+ memory_service_uri : Optional [str ] = None ,
800
+ session_db_url : Optional [str ] = None , # Deprecated
801
+ artifact_storage_uri : Optional [str ] = None , # Deprecated
743
802
):
744
803
"""Deploys an agent to Cloud Run.
745
804
@@ -749,6 +808,8 @@ def cli_deploy_cloud_run(
749
808
750
809
adk deploy cloud_run --project=[project] --region=[region] path/to/my_agent
751
810
"""
811
+ session_service_uri = session_service_uri or session_db_url
812
+ artifact_service_uri = artifact_service_uri or artifact_storage_uri
752
813
try :
753
814
cli_deploy .to_cloud_run (
754
815
agent_folder = agent ,
@@ -761,9 +822,10 @@ def cli_deploy_cloud_run(
761
822
trace_to_cloud = trace_to_cloud ,
762
823
with_ui = with_ui ,
763
824
verbosity = verbosity ,
764
- session_db_url = session_db_url ,
765
- artifact_storage_uri = artifact_storage_uri ,
766
825
adk_version = adk_version ,
826
+ session_service_uri = session_service_uri ,
827
+ artifact_service_uri = artifact_service_uri ,
828
+ memory_service_uri = memory_service_uri ,
767
829
)
768
830
except Exception as e :
769
831
click .secho (f"Deploy failed: { e } " , fg = "red" , err = True )
0 commit comments