diff --git a/agent.py b/agent.py index 7554f64..b88aff2 100644 --- a/agent.py +++ b/agent.py @@ -352,6 +352,20 @@ def _clean_comparison_id(value: str) -> str: return cleaned +def _score_sort_key(row: dict[str, Any]) -> tuple[float, float, int, int, str]: + return ( + -float(row["scores"]["weighted_total"]), + float(row["subtotal"]), + int(row["delivery_days"]), + -int(row["warranty_months"]), + str(row["vendor"]).lower(), + ) + + +def _subtotal_key(row: dict[str, Any]) -> float: + return float(row["subtotal"]) + + def _score_quotes(comparison_id: str, quotes: list[QuoteInput], weights: QuoteWeights) -> dict[str, Any]: quote_rows = [quote.model_dump() for quote in quotes] for row in quote_rows: