o
    d6i                     @   s   d dl m Z  d dlmZmZmZ d dlmZmZmZ d dl	m
Z
mZ d dlZdefddZG d	d
 d
eddZG dd deddZdS )    )datetime)OptionalDictAny)FieldSQLModelColumn)TextJSONNreturnc                   C   s   t t S )zGenerate a unique session ID)struuiduuid4 r   r   //var/www/html/karishye-ai-python/app/schemas.pygenerate_session_id   s   r   c                   @   s   e Zd ZU dZdZedddZee e	d< edddZ
ee	d	< eedd
Zee	d< eejddZee	d< eddZee	d< eeedZee	d< edddZee	d< dS )ChatHistoryz-Chat history model matching the MySQL schema.ai_chat_historyNTdefaultprimary_keyid2   )
max_lengthindexuser_id)default_factoryr   
session_id)r   r   	timestamp   r   type)	sa_columnmessagegeneralr   r   context)__name__
__module____qualname____doc____tablename__r   r   r   int__annotations__r   r   r   r   r   nowr   r!   r   r	   r#   r&   r   r   r   r   r      s   
 r   T)tablec                   @   s0  e Zd ZU dZdZedddZee e	d< eddZ
ee	d	< ed
dZee	d< eddZee	d< edd
dZee e	d< eddZee	d< eeeedZeeef e	d< eddZee	d< eddZee	d< eddZee	d< eddZee	d< eddZee	d< eejdZee	d< eejdZee	d< dS )UserPujaSessionaK  
    User puja session model for tracking puja bookings.
    
    Key Features:
    - UNIQUE constraint on (user_id, session_id, puja_type) ensures ONE row per combination
    - Phone number stored in collected_info JSON as 'phone_number' key
    - All booking data (name, location, date, phone, etc.) stored in collected_info
    ai_user_puja_sessionsNTr   r   r   r    r   d   r   	puja_typer%   	puja_namer   )r   current_question)r   r"   collected_infoF	completed
kb_checkedinvalid_attemptsawaiting_phonephone_collected)r   
created_at
updated_at) r'   r(   r)   r*   r+   r   r   r   r,   r-   r   r   r   r3   r4   r5   dictr   r
   r6   r   r   r7   boolr8   r9   r:   r;   r   r.   r<   r=   r   r   r   r   r0      s"   
  r0   )r   typingr   r   r   sqlmodelr   r   r   
sqlalchemyr	   r
   r   r   r   r   r0   r   r   r   r   <module>   s    