
    Zi                         d dl mZ d dlmZmZmZmZmZ d dlm	Z	 d dl
Z
 edd          Z G d d	ee                   Z G d
 dee                   ZdS )    )abstractmethod)AnyDictGenericProtocolTypeVar)SelfNTT)	covariantc                       e Zd ZdZdefdZededefd            Zde	ee
f         fdZede	ee
f         defd            Zd	S )
JSONSerializablez>A generic interface for objects that can be serialized to JSONreturnc                     dS )Serializes the object to JSONN selfs    K/root/projects/butler/venv/lib64/python3.11/site-packages/chromadb/serde.pyto_json_strzJSONSerializable.to_json_str           json_strc                     dS z!Deserializes the object from JSONNr   )clsr   s     r   from_json_strzJSONSerializable.from_json_str   	     	r   c                     dS )5Serializes the object to a JSON compatible dictionaryNr   r   s    r   to_jsonzJSONSerializable.to_json   r   r   json_mapc                     dS r   r   r   r!   s     r   	from_jsonzJSONSerializable.from_json   r   r   N)__name__
__module____qualname____doc__strr   classmethodr	   r   r   r   r    r$   r   r   r   r   r   	   s        HHS     S T    [c3h     c3h D    [  r   r   c                       e Zd ZdZdefdZdeeef         fdZe	defd            Z
ee	deeef         defd                        ZdS )	BaseModelJSONSerializablezCA mixin for BaseModels that allows a class to be serialized to JSONr   c                 *    |                                  S )r   )model_dump_jsonr   s    r   r   z%BaseModelJSONSerializable.to_json_str"   s    ##%%%r   c                 N    t          j        |                                           S )r   )jsonloadsr.   r   s    r   r    z!BaseModelJSONSerializable.to_json&   s    z$..00111r   c                     dS )zDAbstract method that should be implemented to dump the model to JSONNr   r   s    r   r.   z)BaseModelJSONSerializable.model_dump_json*   s	     	r   r!   c                     dS r   r   r#   s     r   r$   z#BaseModelJSONSerializable.from_json/   s	     	r   N)r%   r&   r'   r(   r)   r   r   r   r    r   r.   r*   r
   r$   r   r   r   r,   r,      s        MM&S & & & &2c3h 2 2 2 2     ^ c3h A    ^ [  r   r,   )abcr   typingr   r   r   r   r   typing_extensionsr	   r0   r
   r   r,   r   r   r   <module>r7      s          8 8 8 8 8 8 8 8 8 8 8 8 8 8 " " " " " " GC4       x{   ,    
     r   