Spaces:
Runtime error
Runtime error
| from typing import List, Dict, Any | |
| from typing_extensions import TypedDict | |
| class ExtractedInformation(TypedDict): | |
| first_name: str | None = None # Customer's first name | |
| last_name: str | None = None # Customer's last name | |
| email: str | None = None # Customer's contact email | |
| phone: str | None = None # Customer's contact phone number | |
| address: str | None = None # Customer's physical address | |
| invoice_number: str | None = None # Reference number for invoices | |
| contract_number: str | None = None # Reference number for contracts | |
| class ExtractedTicket(TypedDict): | |
| title: str | None = None | |
| ticket_num: int | None = None | |
| ticket_description: str | None = None | |
| ticket_type_name: str | None = None | |
| ticket_type_code: str | None = None | |
| class TicketState(TypedDict): | |
| """ | |
| Contains structured information extracted from support request emails. | |
| Fields are optional as not all emails will contain all information types. | |
| """ | |
| # Email Information | |
| email: Dict[str, Any] # Contains subject, sender, body, etc. | |
| # Extracted Information | |
| extracted_information: Dict[str, Any] # Contains extracted information from the email | |
| # user identification | |
| user_id: str | None = None # ID of the user in the system | |
| # Extracted Tickets | |
| extracted_tickets: List[ExtractedTicket] # Contains separated tickets from the email | |
| ticket_type_name: str | None = None # Type of ticket (e.g., invoice_copy, invoice_due_date, etc.) | |
| ticket_type_code: str | None = None # Code for corresponding type of ticket | |
| response: str | None = None # Response generated by the LLM | |
| # Processing metadata | |
| messages: List[Dict[str, Any]] # Track conversation with LLM for analysis | |
| def create_ticket_state() -> TicketState: | |
| extracted_information = ExtractedInformation( | |
| first_name=None, | |
| last_name=None, | |
| email=None, | |
| phone=None, | |
| address=None, | |
| invoice_number=None, | |
| contract_number=None | |
| ) | |
| extracted_tickets: List[ExtractedTicket] = [ | |
| ExtractedTicket( | |
| title=None, | |
| ticket_num=None, | |
| ticket_description=None, | |
| ticket_type_name=None, | |
| ticket_type_code=None, | |
| ) | |
| ] | |
| return TicketState( | |
| email={}, | |
| extracted_information=extracted_information, | |
| user_id=None, | |
| extracted_tickets=extracted_tickets, | |
| messages=[], | |
| ) | |