
    jp                     p    d dl mZmZ d dlZ G d dej                        Z G d dej                        Zy)    )DictListNc                   &    e Zd ZU dZeed<   eed<   y)ConversationThreadItemaU  
    Represents a single message within a conversation thread.

    Each ConversationItem contains the role of the sender (e.g., 'user', 'assistant', 'system')
    and the content of the message. This structured format allows for consistent representation
    of messages across different conversation interfaces and evaluation systems.
    rolecontentN)__name__
__module____qualname____doc__str__annotations__     /Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/opik/api_objects/conversation/conversation_thread.pyr   r      s     ILr   r   c                       e Zd ZU dZ ej
                  e      Zee	   e
d<   de	ddfdZdeddfd	Zdeddfd
ZdeddfdZdeeeef      fdZy)ConversationThreada  
    Represents a conversation thread composed of multiple conversation items.

    This class is built using Pydantic's BaseModel to ensure type validation and data
    integrity. It maintains a list of conversation items, where each item is an
    instance of the `ConversationThreadItem` class. The conversation thread allows
    adding messages from various roles, such as assistant, user, and system, and
    provides the ability to export the conversation data as a JSON-serializable list.

    Attributes:
        discussion (List[ConversationThreadItem]): A list of conversation items
            representing the dialogue between the roles.
    )default_factory
discussionitemreturnNc                 :    | j                   j                  |       y N)r   appendselfr   s     r   add_itemzConversationThread.add_item$   s    t$r   messagec                 <    | j                  t        d|             y )N	assistantr   r   r   r   r   r   s     r   add_assistant_messagez(ConversationThread.add_assistant_message'   s    ,+wOPr   c                 <    | j                  t        d|             y )Nuserr!   r"   r#   s     r   add_user_messagez#ConversationThread.add_user_message*   s    ,&'JKr   c                 <    | j                  t        d|             y )Nsystemr!   r"   r#   s     r   add_system_messagez%ConversationThread.add_system_message-   s    ,(GLMr   c                 \    | j                   D cg c]  }|j                          c}S c c}w r   )r   
model_dumpr   s     r   as_json_listzConversationThread.as_json_list0   s%    .2oo>od!o>>>s   ))r	   r
   r   r   pydanticFieldlistr   r   r   r   r   r   r$   r'   r*   r   r-   r   r   r   r   r      s     0>x~~d/SJ+,S%3 % %QS QT QL L LN# N$ N?d4S>2 ?r   r   )typingr   r   r.   	BaseModelr   r   r   r   r   <module>r3      s/     
X// 
?++ ?r   