refactored: to utilise the google adk and production grade agent
Some checks failed
validation / verify (push) Failing after 10s
Some checks failed
validation / verify (push) Failing after 10s
This commit is contained in:
@@ -1,27 +1,26 @@
|
||||
"""Evaluation Harness Runner for GCP Solution Architecture Agent."""
|
||||
"""Evaluation Harness Runner for GCP Solution Architecture Agent.
|
||||
|
||||
Uses google.adk.evaluation.Evaluator with PostgreSQL database metrics persistence.
|
||||
"""
|
||||
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from app.adk.evaluation import ADKEvaluator
|
||||
from app.config import get_settings
|
||||
from app.skills.loader import SkillLoader
|
||||
from app.workflows.gcp_architecture_graph import create_agent
|
||||
from eval.metrics import evaluate_case_run
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class EvalHarness:
|
||||
"""Offline Evaluation Harness for running benchmark suites against agent workflows."""
|
||||
"""Offline Evaluation Harness for running benchmark suites against ADK agents."""
|
||||
|
||||
def __init__(self, dataset_path: Path | None = None) -> None:
|
||||
settings = get_settings()
|
||||
self.dataset_path = dataset_path or settings.EVAL_DATASET_PATH
|
||||
self.skill_loader = SkillLoader(settings.SKILLS_DIR)
|
||||
self.skill_loader.load_skills()
|
||||
self.agent = create_agent(self.skill_loader)
|
||||
self.evaluator = ADKEvaluator()
|
||||
|
||||
def load_benchmark_cases(self) -> List[Dict[str, Any]]:
|
||||
"""Load benchmark dataset JSON."""
|
||||
@@ -33,7 +32,7 @@ class EvalHarness:
|
||||
return json.load(f)
|
||||
|
||||
def run_eval_suite(self) -> Dict[str, Any]:
|
||||
"""Execute all benchmark test cases and compile scoring metrics."""
|
||||
"""Execute all benchmark test cases through ADKEvaluator and compile scoring metrics."""
|
||||
cases = self.load_benchmark_cases()
|
||||
if not cases:
|
||||
return {"status": "error", "message": "No benchmark cases loaded."}
|
||||
@@ -42,15 +41,8 @@ class EvalHarness:
|
||||
total_passed = 0
|
||||
|
||||
for case in cases:
|
||||
logger.info("Evaluating benchmark case: %s", case.get("id"))
|
||||
initial_state = {
|
||||
"workflow_request": case.get("workflow_request", ""),
|
||||
"target_dir": ".",
|
||||
"active_skills": [],
|
||||
}
|
||||
|
||||
final_state = self.agent.invoke(initial_state)
|
||||
eval_result = evaluate_case_run(final_state, case)
|
||||
logger.info("Evaluating ADK benchmark case: %s", case.get("id"))
|
||||
eval_result = self.evaluator.evaluate_benchmark_case(case)
|
||||
results.append(eval_result)
|
||||
|
||||
if eval_result.get("passed"):
|
||||
@@ -73,7 +65,7 @@ def main() -> None:
|
||||
"""CLI Runner for Evaluation Harness."""
|
||||
harness = EvalHarness()
|
||||
summary = harness.run_eval_suite()
|
||||
print("=== GCP Solution Architecture Agent Benchmark Summary ===")
|
||||
print("=== GCP Solution Architecture Agent ADK Benchmark Summary ===")
|
||||
print(json.dumps(summary, indent=2))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user