This commit is contained in:
+18
-5
@@ -528,12 +528,13 @@ class ContinualPlanRunner:
|
||||
|
||||
async def _draft_buying_message(self, plan: dict[str, Any], item: dict[str, Any], candidate: dict[str, Any]) -> dict[str, Any]:
|
||||
tone = (plan.get("constraints") or {}).get("message_tone") or "polite and concise"
|
||||
greeting = "Hi" if "professional" in str(tone).casefold() or "polite" in str(tone).casefold() else "Hey"
|
||||
build_context = self._plan_build_context(plan["objective"])
|
||||
message = (
|
||||
f"Hi, I am interested in your {candidate.get('title') or item['item_name']} listing "
|
||||
f"for {self._format_price(candidate.get('price'), candidate.get('currency'))}. "
|
||||
f"Is it still available? I am trying to complete: {plan['objective']}. "
|
||||
f"Tone note: {tone}."
|
||||
)
|
||||
f"{greeting}, is your {candidate.get('title') or item['item_name']} listing still available "
|
||||
f"for {self._format_price(candidate.get('price'), candidate.get('currency'))}? "
|
||||
f"{build_context}If you still have it, I can move quickly."
|
||||
).strip()
|
||||
return await self.tools.draft_negotiation_message(
|
||||
message=message,
|
||||
id_listing=self._int_or_none(candidate.get("listing_id")),
|
||||
@@ -543,6 +544,18 @@ class ContinualPlanRunner:
|
||||
listing_slug=candidate.get("listing_slug"),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _plan_build_context(objective: str) -> str:
|
||||
text = str(objective or "").strip().rstrip(".")
|
||||
if not text:
|
||||
return ""
|
||||
lowered = text.casefold()
|
||||
if "polaris" in lowered:
|
||||
return "I'm putting together parts for a Polaris build. "
|
||||
if "mission" in lowered:
|
||||
return "I'm trying to wrap up a mission build. "
|
||||
return "I'm sourcing parts for a build. "
|
||||
|
||||
@staticmethod
|
||||
def _candidate_score(listing: dict[str, Any], item: dict[str, Any], preferred_locations: list[str]) -> float:
|
||||
price = float(listing.get("price") or 10**12)
|
||||
|
||||
Reference in New Issue
Block a user