a
    ”˜ëjú  ã                   @  s|   U d Z ddlmZ ddlZddlmZ ddlmZ ej	rDddlmZ dZ
ded< d	d
dœdd„Zddddœdd„ZdgZdS )zŒUUID utility functions.

This module exports a uuid7 function to generate monotonic, time-ordered UUIDs
for tracing and similar operations.
é    )ÚannotationsN)ÚUUID)Úuuid7i Êš;ztyping.FinalÚ_NANOS_PER_SECONDÚintztuple[int, int])ÚnanosecondsÚreturnc                 C  s   t | tƒ\}}||fS )zDSplit a nanosecond timestamp into seconds and remaining nanoseconds.)Údivmodr   ©r   ÚsecondsÚnanos© r   úX/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/langchain_core/utils/uuid.pyÚ_to_timestamp_and_nanos   s    r   z
int | Noner   c                 C  s&   | du rt ƒ S t| ƒ\}}t ||d�S )zäGenerate a UUID from a Unix timestamp in nanoseconds and random bits.

    UUIDv7 objects feature monotonicity within a millisecond.

    Args:
        nanoseconds: Optional ns timestamp. If not provided, uses current time.
    N)Ú	timestampr   )Ú_uuid_utils_uuid7r   r
   r   r   r   r      s    r   )N)Ú__doc__Ú
__future__r   ÚtypingÚuuidr   Zuuid_utils.compatr   r   ÚTYPE_CHECKINGr   Ú__annotations__r   Ú__all__r   r   r   r   Ú<module>   s   