from langchain_core.tools import tool from pydantic import BaseModel, Field from typing import Literal class TransferCallArgs(BaseModel): destination: Literal["sales", "service", "parts"] = Field( description="The department the call is being transferred to." ) @tool(args_schema=TransferCallArgs) def transfer_call(destination: str): """Transfer the call to a real person or department.""" return f"Attempting to transfer call to {destination}..." class LeaveMessageArgs(BaseModel): first_name: str = Field(description="The first name of the customer leaving the message.") last_name: str = Field(description="The last name or initial of the customer leaving the message.") phone_number: str = Field(description="The phone number of the customer, used for sending confirmation and any follow-up information.") message: str = Field(description="The content of the message left by the customer.") sms_consent: bool = Field(description="The customer's consent to receive confirmation and further communication via text about their message.") destination: str = Field(description="The department to which the message is being sent.") @tool(args_schema=LeaveMessageArgs) def leave_message( first_name: str, last_name: str, phone_number: str, message: str, sms_consent: bool, destination: str, ): """Allows a customer to leave a message for a department.""" return f"Message for {destination} from {first_name} {last_name} ({phone_number}): '{message}'. SMS consent: {sms_consent}" class GoToArgs(BaseModel): destination: Literal["customer_search_function", "service_intermediate"] = Field( description="The target node to transition to." ) @tool(args_schema=GoToArgs) def go_to(destination: str): """Transition to another node in the conversation graph.""" return f"Transitioning to {destination}..."