Spaces:
Running on Zero
Running on Zero
Upload community_contributions/damola-adewunmi/agents/strategist.py with huggingface_hub
Browse files
community_contributions/damola-adewunmi/agents/strategist.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Strategist Agent: summarize valued deals into a table for the Gradio UI.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from typing import Any
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def strategist_node(state: dict[str, Any]) -> dict[str, Any]:
|
| 9 |
+
"""
|
| 10 |
+
Node: turn valued_deals into summary_table (list of rows) and a short message.
|
| 11 |
+
"""
|
| 12 |
+
deals = state.get("valued_deals") or []
|
| 13 |
+
rows = []
|
| 14 |
+
for d in deals:
|
| 15 |
+
retailer = d.get("retailer", "")
|
| 16 |
+
denom = d.get("denomination_gbp", "")
|
| 17 |
+
price = d.get("price_gbp", "")
|
| 18 |
+
discount = d.get("discount_pct", "")
|
| 19 |
+
verdict = d.get("verdict", "")
|
| 20 |
+
url = d.get("url", "")
|
| 21 |
+
rows.append([str(retailer), str(denom), str(price), str(discount), verdict, str(url)])
|
| 22 |
+
n = len(rows)
|
| 23 |
+
summary_message = (
|
| 24 |
+
f"Found {n} PlayStation UK gift card deal(s). Strong Buy = discount >12%."
|
| 25 |
+
if n else "No deals found from search results."
|
| 26 |
+
)
|
| 27 |
+
return {"summary_table": rows, "summary_message": summary_message}
|