github-actions[bot]
Automated deployment from GitHub Actions: a9d5a91de63ad7224bafe6039fb2b7479388fbf4
0a8c81b Download src/agents/selector_agent.py from VLTA-AI/dropshop: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/VLTA-AI/dropshop/resolve/main/src/agents/selector_agent.py
- Command line
-
hf download hf://spaces/VLTA-AI/dropshop/src/agents/selector_agent.py
-
curl -L -o selector_agent.py https://huggingface.co/spaces/VLTA-AI/dropshop/resolve/main/src/agents/selector_agent.py
1.45 kB
| from pydantic import BaseModel | |
| from typing import Optional | |
| from src.skills.roi_calculator import calculate_roi | |
| class ProductIdea(BaseModel): | |
| id: str | |
| source_url: str | |
| sales_volume: int | |
| est_total_cost_cny: float | |
| recommended_retail_price_usd: float | |
| roi_score: Optional[float] = None | |
| status: str = "SCRAPED" | |
| def process_sourcing_event(data: dict) -> dict: | |
| idea = ProductIdea( | |
| id=data["productIdeaId"], | |
| source_url=data["sourceUrl"], | |
| sales_volume=data.get("salesVolume", 0), | |
| est_total_cost_cny=data["priceCny"], | |
| recommended_retail_price_usd=data["retailPriceUsd"], | |
| ) | |
| roi_result = calculate_roi( | |
| price_cny=data["priceCny"], | |
| length_cm=data["lengthCm"], | |
| width_cm=data["widthCm"], | |
| height_cm=data["heightCm"], | |
| actual_weight_kg=data["actualWeightKg"], | |
| retail_price_usd=data["retailPriceUsd"] | |
| ) | |
| idea.roi_score = roi_result.roi_percentage | |
| if roi_result.passed_threshold: | |
| idea.status = "SELECTED" | |
| else: | |
| idea.status = "DISCARDED" | |
| # TODO: Connect to Supabase via SQLModel to persist the state | |
| return { | |
| "Status": "🟢 Success", | |
| "Generated_Artifacts": idea.model_dump(), | |
| "Confidence_Score": 100, | |
| "Next_Agent_Suggestion": "content-agent" if idea.status == "SELECTED" else "end_of_workflow", | |
| "roi_breakdown": roi_result.breakdown | |
| } | |