uuid7() — langchain Function Reference
Architecture documentation for the uuid7() function in uuid.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 17117e0a_43b2_e8a5_ecd1_dae57e2c71b8["uuid7()"] 5d39aa62_9c2a_27bb_12c2_7b5f687b9d8f["uuid.py"] 17117e0a_43b2_e8a5_ecd1_dae57e2c71b8 -->|defined in| 5d39aa62_9c2a_27bb_12c2_7b5f687b9d8f 17117e0a_43b2_e8a5_ecd1_dae57e2c71b8["uuid7()"] 17117e0a_43b2_e8a5_ecd1_dae57e2c71b8 -->|calls| 17117e0a_43b2_e8a5_ecd1_dae57e2c71b8 17117e0a_43b2_e8a5_ecd1_dae57e2c71b8["uuid7()"] 17117e0a_43b2_e8a5_ecd1_dae57e2c71b8 -->|calls| 17117e0a_43b2_e8a5_ecd1_dae57e2c71b8 e6c4ea8a_07af_4a51_efb8_45ab60dc6f9a["_to_timestamp_and_nanos()"] 17117e0a_43b2_e8a5_ecd1_dae57e2c71b8 -->|calls| e6c4ea8a_07af_4a51_efb8_45ab60dc6f9a style 17117e0a_43b2_e8a5_ecd1_dae57e2c71b8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/utils/uuid.py lines 26–54
def uuid7(nanoseconds: int | None = None) -> UUID:
"""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.
Returns:
A UUIDv7 object.
"""
# --- 48 --- -- 4 -- --- 12 --- -- 2 -- --- 30 --- - 32 -
# unix_ts_ms | version | counter_hi | variant | counter_lo | random
#
# 'counter = counter_hi | counter_lo' is a 42-bit counter constructed
# with Method 1 of RFC 9562, §6.2, and its MSB is set to 0.
#
# 'random' is a 32-bit random value regenerated for every new UUID.
#
# If multiple UUIDs are generated within the same millisecond, the LSB
# of 'counter' is incremented by 1. When overflowing, the timestamp is
# advanced and the counter is reset to a random 42-bit integer with MSB
# set to 0.
# For now, just delegate to the uuid_utils implementation
if nanoseconds is None:
return _uuid_utils_uuid7()
seconds, nanos = _to_timestamp_and_nanos(nanoseconds)
return _uuid_utils_uuid7(timestamp=seconds, nanos=nanos)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does uuid7() do?
uuid7() is a function in the langchain codebase, defined in libs/core/langchain_core/utils/uuid.py.
Where is uuid7() defined?
uuid7() is defined in libs/core/langchain_core/utils/uuid.py at line 26.
What does uuid7() call?
uuid7() calls 2 function(s): _to_timestamp_and_nanos, uuid7.
What calls uuid7()?
uuid7() is called by 1 function(s): uuid7.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free