Home / Function/ get_time() — langchain Function Reference

get_time() — langchain Function Reference

Architecture documentation for the get_time() function in _sql_record_manager.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  be7e72a6_66bf_ecc2_56cf_9470c1c3503c["get_time()"]
  9d7938c1_1c25_4cae_be80_9fc00a5ed077["SQLRecordManager"]
  be7e72a6_66bf_ecc2_56cf_9470c1c3503c -->|defined in| 9d7938c1_1c25_4cae_be80_9fc00a5ed077
  5c882370_32cd_fc53_c3f7_ae3deb69e322["update()"]
  5c882370_32cd_fc53_c3f7_ae3deb69e322 -->|calls| be7e72a6_66bf_ecc2_56cf_9470c1c3503c
  82b22123_4423_ea4d_765a_075b780b8c2e["_make_session()"]
  be7e72a6_66bf_ecc2_56cf_9470c1c3503c -->|calls| 82b22123_4423_ea4d_765a_075b780b8c2e
  style be7e72a6_66bf_ecc2_56cf_9470c1c3503c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/indexes/_sql_record_manager.py lines 188–218

    def get_time(self) -> float:
        """Get the current server time as a timestamp.

        Please note it's critical that time is obtained from the server since
        we want a monotonic clock.
        """
        with self._make_session() as session:
            # * SQLite specific implementation, can be changed based on dialect.
            # * For SQLite, unlike unixepoch it will work with older versions of SQLite.
            # ----
            # julianday('now'): Julian day number for the current date and time.
            # The Julian day is a continuous count of days, starting from a
            # reference date (Julian day number 0).
            # 2440587.5 - constant represents the Julian day number for January 1, 1970
            # 86400.0 - constant represents the number of seconds
            # in a day (24 hours * 60 minutes * 60 seconds)
            if self.dialect == "sqlite":
                query = text("SELECT (julianday('now') - 2440587.5) * 86400.0;")
            elif self.dialect == "postgresql":
                query = text("SELECT EXTRACT (EPOCH FROM CURRENT_TIMESTAMP);")
            else:
                msg = f"Not implemented for dialect {self.dialect}"
                raise NotImplementedError(msg)

            dt = session.execute(query).scalar()
            if isinstance(dt, decimal.Decimal):
                dt = float(dt)
            if not isinstance(dt, float):
                msg = f"Unexpected type for datetime: {type(dt)}"
                raise AssertionError(msg)  # noqa: TRY004
            return dt

Domain

Subdomains

Called By

Frequently Asked Questions

What does get_time() do?
get_time() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/indexes/_sql_record_manager.py.
Where is get_time() defined?
get_time() is defined in libs/langchain/langchain_classic/indexes/_sql_record_manager.py at line 188.
What does get_time() call?
get_time() calls 1 function(s): _make_session.
What calls get_time()?
get_time() is called by 1 function(s): update.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free