Home / Function/ update() — langchain Function Reference

update() — langchain Function Reference

Architecture documentation for the update() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  abe5b1d2_7989_73c6_22d5_99489342b630["update()"]
  84fe5b79_2fbc_b61f_ca25_e76f82c76cf4["InMemoryRecordManager"]
  abe5b1d2_7989_73c6_22d5_99489342b630 -->|defined in| 84fe5b79_2fbc_b61f_ca25_e76f82c76cf4
  9a2cabcb_0298_fe46_eeb9_77e538307565["update()"]
  9a2cabcb_0298_fe46_eeb9_77e538307565 -->|calls| abe5b1d2_7989_73c6_22d5_99489342b630
  c01fa23b_401c_9c3f_6a58_f302cfe5d794["aupdate()"]
  c01fa23b_401c_9c3f_6a58_f302cfe5d794 -->|calls| abe5b1d2_7989_73c6_22d5_99489342b630
  174eed09_93ad_e8b1_2fb1_996aa4c2fd91["get_time()"]
  abe5b1d2_7989_73c6_22d5_99489342b630 -->|calls| 174eed09_93ad_e8b1_2fb1_996aa4c2fd91
  9a2cabcb_0298_fe46_eeb9_77e538307565["update()"]
  abe5b1d2_7989_73c6_22d5_99489342b630 -->|calls| 9a2cabcb_0298_fe46_eeb9_77e538307565
  style abe5b1d2_7989_73c6_22d5_99489342b630 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/indexing/base.py lines 269–304

    def update(
        self,
        keys: Sequence[str],
        *,
        group_ids: Sequence[str | None] | None = None,
        time_at_least: float | None = None,
    ) -> None:
        """Upsert records into the database.

        Args:
            keys: A list of record keys to upsert.
            group_ids: A list of group IDs corresponding to the keys.

            time_at_least: Optional timestamp. Implementation can use this
                to optionally verify that the timestamp IS at least this time
                in the system that stores.
                E.g., use to validate that the time in the postgres database
                is equal to or larger than the given timestamp, if not
                raise an error.
                This is meant to help prevent time-drift issues since
                time may not be monotonically increasing!

        Raises:
            ValueError: If the length of keys doesn't match the length of group
                ids.
            ValueError: If time_at_least is in the future.
        """
        if group_ids and len(keys) != len(group_ids):
            msg = "Length of keys must match length of group_ids"
            raise ValueError(msg)
        for index, key in enumerate(keys):
            group_id = group_ids[index] if group_ids else None
            if time_at_least and time_at_least > self.get_time():
                msg = "time_at_least must be in the past"
                raise ValueError(msg)
            self.records[key] = {"group_id": group_id, "updated_at": self.get_time()}

Subdomains

Called By

Frequently Asked Questions

What does update() do?
update() is a function in the langchain codebase, defined in libs/core/langchain_core/indexing/base.py.
Where is update() defined?
update() is defined in libs/core/langchain_core/indexing/base.py at line 269.
What does update() call?
update() calls 2 function(s): get_time, update.
What calls update()?
update() is called by 2 function(s): aupdate, update.

Analyze Your Own Codebase

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

Try Supermodel Free