Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions examples/hotel_receptionist/get_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

Never read the full card number or the security code back to the caller; refer to the card by its last four digits only. If a tool rejects a value, ask the caller to repeat just that detail - don't start the whole card over. If the caller switches cards mid-way, just record the new values; recording a field again replaces it.

If the caller refuses to provide the card, call decline_card_capture.
If the caller refuses to provide the card, or has no other card to give after theirs came back expired, don't keep asking - call decline_card_capture with the reason.
"""


Expand Down Expand Up @@ -122,7 +122,11 @@ async def record_expiration(self, month: int, year: int) -> str:
if not 0 <= year <= 99:
raise ToolError("that expiration year is invalid - ask the caller to repeat it")
if (2000 + year, month) < (TODAY.year, TODAY.month):
raise ToolError("that date is in the past, the card is expired - ask for another card")
raise ToolError(
f"the date I have is {month:02d}/{year:02d}, which is in the past - confirm the "
"expiration with the caller; if the card really is expired and they have no "
"other card, call decline_card_capture"
)
self._expiration = f"{month:02d}/{year:02d}"
return f"expiration recorded | {self._status()}"

Expand Down Expand Up @@ -180,10 +184,10 @@ async def confirm_card(self) -> None:

@function_tool(flags=ToolFlag.IGNORE_ON_ENTER)
async def decline_card_capture(self, reason: str) -> None:
"""The caller explicitly refuses to provide their card.
"""End the card capture without a card: the caller refuses to provide one, or has no other card after theirs came back expired.

Args:
reason: A short explanation of why the caller declined.
reason: A short explanation of why no card could be taken.
"""
if not self.done():
self.complete(ToolError(f"couldn't get the card details: {reason}"))