Generates eval cases dynamically and adds them to the given eval set. Uses Vertex AI Eval SDK to generate conversation scenarios based on an Agent's info and definitions. It will automatically create the empty eval_set if it has not been created in advance. Args: agent_module_file_path
(
agent_module_file_path: str,
eval_set_id: str,
user_simulation_config_file: str,
eval_storage_uri: str | None = None,
log_level: str = "INFO",
)
| 1467 | ) |
| 1468 | @eval_options() |
| 1469 | def cli_generate_eval_cases( |
| 1470 | agent_module_file_path: str, |
| 1471 | eval_set_id: str, |
| 1472 | user_simulation_config_file: str, |
| 1473 | eval_storage_uri: str | None = None, |
| 1474 | log_level: str = "INFO", |
| 1475 | ): |
| 1476 | """Generates eval cases dynamically and adds them to the given eval set. |
| 1477 | |
| 1478 | Uses Vertex AI Eval SDK to generate conversation scenarios based on an |
| 1479 | Agent's info and definitions. It will automatically create the empty eval_set |
| 1480 | if it has not been created in advance. |
| 1481 | |
| 1482 | Args: |
| 1483 | agent_module_file_path: The path to the agent module file. |
| 1484 | eval_set_id: The id of the eval set to generate cases for. |
| 1485 | user_simulation_config_file: The path to the user simulation config file. |
| 1486 | eval_storage_uri: The eval storage uri. |
| 1487 | log_level: The log level. |
| 1488 | """ |
| 1489 | logs.setup_adk_logger(getattr(logging, log_level.upper())) |
| 1490 | try: |
| 1491 | from ..evaluation._vertex_ai_scenario_generation_facade import ScenarioGenerator |
| 1492 | from ..evaluation.conversation_scenarios import ConversationGenerationConfig |
| 1493 | from ..evaluation.eval_case import EvalCase |
| 1494 | from ..evaluation.eval_case import SessionInput |
| 1495 | from .cli_eval import get_eval_sets_manager |
| 1496 | from .cli_eval import get_root_agent |
| 1497 | from .utils.state import create_empty_state |
| 1498 | |
| 1499 | except ModuleNotFoundError as mnf: |
| 1500 | raise click.ClickException(MISSING_EVAL_DEPENDENCIES_MESSAGE) from mnf |
| 1501 | |
| 1502 | app_name = os.path.basename(agent_module_file_path) |
| 1503 | agents_dir = os.path.dirname(agent_module_file_path) |
| 1504 | |
| 1505 | try: |
| 1506 | eval_sets_manager = get_eval_sets_manager(eval_storage_uri, agents_dir) |
| 1507 | root_agent = get_root_agent(agent_module_file_path) |
| 1508 | |
| 1509 | # Try to create if it doesn't already exist. |
| 1510 | if ( |
| 1511 | eval_sets_manager.get_eval_set( |
| 1512 | app_name=app_name, eval_set_id=eval_set_id |
| 1513 | ) |
| 1514 | is None |
| 1515 | ): |
| 1516 | eval_sets_manager.create_eval_set( |
| 1517 | app_name=app_name, eval_set_id=eval_set_id |
| 1518 | ) |
| 1519 | click.echo(f"Eval set '{eval_set_id}' created for app '{app_name}'.") |
| 1520 | else: |
| 1521 | click.echo(f"Eval set '{eval_set_id}' already exists.") |
| 1522 | |
| 1523 | with open(user_simulation_config_file, "r") as f: |
| 1524 | config = ConversationGenerationConfig.model_validate_json(f.read()) |
| 1525 | |
| 1526 | generator = ScenarioGenerator() |
nothing calls this directly
no test coverage detected