MCPcopy Create free account
hub / github.com/google/adk-samples / compare_vendor

Function compare_vendor

python/agents/invoice-processing/eval/eval.py:254–281  ·  view source on GitHub ↗

Compare vendor information.

(gt: dict, agent: dict)

Source from the content-addressed store, hash-verified

252
253
254def compare_vendor(gt: dict, agent: dict) -> dict:
255 """Compare vendor information."""
256 gt_vendor = gt.get("Vendor Information") or {}
257 agent_vendor = agent.get("Vendor Information") or {}
258
259 # Vendor name — normalized comparison
260 gt_name = normalize_string(gt_vendor.get("Vendor Name", ""))
261 agent_name = normalize_string(agent_vendor.get("Vendor Name", ""))
262 name_match = gt_name == agent_name
263
264 # Tax ID — exact after stripping whitespace
265 gt_tax_id = str(gt_vendor.get("Tax ID", "")).replace(" ", "").strip()
266 agent_tax_id = str(agent_vendor.get("Tax ID", "")).replace(" ", "").strip()
267 tax_id_match = gt_tax_id == agent_tax_id
268
269 return {
270 "Vendor Name": {
271 "ground_truth": gt_vendor.get("Vendor Name", ""),
272 "agent": agent_vendor.get("Vendor Name", ""),
273 "match": name_match,
274 },
275 "Tax ID": {
276 "ground_truth": gt_vendor.get("Tax ID", ""),
277 "agent": agent_vendor.get("Tax ID", ""),
278 "match": tax_id_match,
279 },
280 "all_match": name_match and tax_id_match,
281 }
282
283
284def compare_header(gt: dict, agent: dict) -> dict:

Callers 1

_evaluate_legacyFunction · 0.85

Calls 2

normalize_stringFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected