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

Function parse_line_items

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

Parse the Line Items field (stored as JSON string in the schema).

(line_items_field: Any)

Source from the content-addressed store, hash-verified

147
148
149def parse_line_items(line_items_field: Any) -> list[dict]:
150 """Parse the Line Items field (stored as JSON string in the schema)."""
151 if line_items_field is None:
152 return []
153 if isinstance(line_items_field, list):
154 return line_items_field
155 if isinstance(line_items_field, str):
156 try:
157 parsed = json.loads(line_items_field)
158 return parsed if isinstance(parsed, list) else []
159 except (json.JSONDecodeError, TypeError):
160 return []
161 return []
162
163
164def compare_decision(

Callers 2

compare_line_itemsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected