o
    i                     @   sR   d dl mZ d dlmZ G dd dejZG dd dejZG dd dejZd	S )
    )models)Callc                   @   s   e Zd ZdZejeejdddZej	dddZ
ej	dddZejed	d
Zejedd
Zejedd
ZejddddZejdg dddddZejedd
Zejedd
ZejddZejddZG dd dZdd Zedd Zedd Zedd  Zd!S )"Conversationz=Model representing a conversation that occurred during a callconversationz%The call this conversation belongs to	on_deleterelated_name	help_textTz#Full transcript of the conversation)blankr	   z(AI-generated summary of the conversationz0List of topics discussed during the conversationdefaultr	   z6Key memories or stories shared during the conversationz)Emotions detected during the conversationz!Overall sentiment score (-1 to 1)nullr
   r	      ))lowLow)mediumMedium)highHighz+Level of engagement during the conversation)
max_lengthchoicesr   r
   r	   z!Topics to discuss in future callsz Questions to ask in future callsauto_now_addauto_nowc                   @   s   e Zd ZdgZdS )zConversation.Meta-created_atN__name__
__module____qualname__ordering r"   r"   -/var/www/html/philips/conversations/models.pyMetaH   s    
r$   c                 C   s   d| j jj d| jd S )NzConversation with z - z%Y-%m-%d %H:%M)callseniorname
created_atstrftimeselfr"   r"   r#   __str__K   s   zConversation.__str__c                 C      | j jS )z*Return the senior from the associated call)r%   r&   r*   r"   r"   r#   r&   N      zConversation.seniorc                 C   r-   )zReturn the duration of the call)r%   durationr*   r"   r"   r#   r/   S   r.   zConversation.durationc                 C   s   t | jo| jS )zGReturn True if the conversation was meaningful (has summary and topics))boolsummarytopics_discussedr*   r"   r"   r#   is_meaningfulX   s   zConversation.is_meaningfulN) r   r   r    __doc__r   OneToOneFieldr   CASCADEr%   	TextField
transcriptr1   	JSONFieldlistr2   key_memoriesemotions_detected
FloatFieldsentiment_score	CharFieldengagement_levelfollow_up_topicsfollow_up_questionsDateTimeFieldr(   
updated_atr$   r,   propertyr&   r/   r3   r"   r"   r"   r#   r      st    

r   c                   @   s   e Zd ZdZg dZejdejdddZeje	ejdddZ
ejded	d
ZejdddZejddZejdddZejeddZejdddZejddddZejddZejddZG dd dZdd Zdd  Zd!S )"MemoryzAModel for storing important memories extracted from conversations))storyStory)factFact)
preference
Preference)relationshipRelationship)
experience
Experience)achievementAchievementseniors.Seniormemoriesz!The senior this memory belongs tor   z/The conversation this memory was extracted fromr   zType of memoryr   r   r	      zShort title for the memoryr   r	   zThe memory contentr	         ?z0Importance score (0-1) for prioritizing memoriesr   z Tags for categorizing the memoryr   z@Number of times this memory has been referenced in conversationsTz$When this memory was last referencedr   r   r   c                   @   s   e Zd ZddgZddgZdS )zMemory.Metaz-importance_scorer   r&   titleN)r   r   r    r!   unique_togetherr"   r"   r"   r#   r$      s    r$   c                 C      | j  d| j dS Nz ())rZ   memory_typer*   r"   r"   r#   r,         zMemory.__str__c                 C   s0   |  j d7  _ ddlm} | | _|   dS )z0Mark this memory as referenced in a conversation   r   )timezoneN)times_referenceddjango.utilsrb   nowlast_referencedsave)r+   rb   r"   r"   r#   mark_referenced   s   
zMemory.mark_referencedN)r   r   r    r4   MEMORY_TYPESr   
ForeignKeyr6   r&   r   r   r?   r_   rZ   r7   contentr=   importance_scorer9   r:   tagsPositiveIntegerFieldrc   rC   rf   r(   rD   r$   r,   rh   r"   r"   r"   r#   rF   ^   s^    
rF   c                   @   s   e Zd ZdZg dZejdejdddZej	dedd	Z
ej	d
ddZejddZejeddZejdddZejddZejddZG dd dZdd ZdS )ConversationInsightz=Model for storing insights derived from conversation analysis))
mood_trendz
Mood Trend)interest_changezInterest Change)health_concernzHealth Concern)social_patternzSocial Pattern)memory_patternzMemory Pattern)communication_stylezCommunication StylerS   insightsz"The senior this insight belongs tor   r   zType of insightrU   rV   zTitle of the insightrW   zDescription of the insightrX   zSupporting data for the insightr   rY   z&Confidence score (0-1) for the insightTr   r   c                   @   s   e Zd ZddgZdS )zConversationInsight.Metaz-confidence_scorer   Nr   r"   r"   r"   r#   r$      s    r$   c                 C   r\   r]   )rZ   insight_typer*   r"   r"   r#   r,      r`   zConversationInsight.__str__N)r   r   r    r4   INSIGHT_TYPESr   rj   r6   r&   r?   rw   rZ   r7   descriptionr9   dictdatar=   confidence_scorerC   r(   rD   r$   r,   r"   r"   r"   r#   ro      s>    
ro   N)	django.dbr   calls.modelsr   Modelr   rF   ro   r"   r"   r"   r#   <module>   s
    YN