upsert() — langchain Function Reference
Architecture documentation for the upsert() function in in_memory.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d6b519d2_9c69_7fcd_1cc8_eb8ecb55cc54["upsert()"] 1d0fbace_6fae_3047_1833_452998c80662["InMemoryDocumentIndex"] d6b519d2_9c69_7fcd_1cc8_eb8ecb55cc54 -->|defined in| 1d0fbace_6fae_3047_1833_452998c80662 style d6b519d2_9c69_7fcd_1cc8_eb8ecb55cc54 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/indexing/in_memory.py lines 32–58
def upsert(self, items: Sequence[Document], /, **kwargs: Any) -> UpsertResponse:
"""Upsert documents into the index.
Args:
items: Sequence of documents to add to the index.
**kwargs: Additional keyword arguments.
Returns:
A response object that contains the list of IDs that were
successfully added or updated in the index and the list of IDs that
failed to be added or updated.
"""
ok_ids = []
for item in items:
if item.id is None:
id_ = str(uuid.uuid4())
item_ = item.model_copy()
item_.id = id_
else:
item_ = item
id_ = item.id
self.store[id_] = item_
ok_ids.append(cast("str", item_.id))
return UpsertResponse(succeeded=ok_ids, failed=[])
Domain
Subdomains
Source
Frequently Asked Questions
What does upsert() do?
upsert() is a function in the langchain codebase, defined in libs/core/langchain_core/indexing/in_memory.py.
Where is upsert() defined?
upsert() is defined in libs/core/langchain_core/indexing/in_memory.py at line 32.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free