Skip to content

Commit

Permalink
core : update the class docs of InMemoryVectorStore in in_memory.py (#…
Browse files Browse the repository at this point in the history
…29781)

- **Description:** Add the new introduction about checking `store` in
in_memory.py, It’s necessary and useful for beginners.
```python
Check Documents:
    .. code-block:: python
    
        for doc in vector_store.store.values():
            print(doc)
```

---------

Co-authored-by: Chester Curme <chester.curme@gmail.com>
  • Loading branch information
GoogTech and ccurme authored Feb 13, 2025
1 parent b82cef3 commit 76d3275
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libs/core/langchain_core/vectorstores/in_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ class InMemoryVectorStore(VectorStore):
documents = [document_1, document_2, document_3]
vector_store.add_documents(documents=documents)
Inspect documents:
.. code-block:: python
top_n = 10
for index, (id, doc) in enumerate(vector_store.store.items()):
if index < top_n:
# docs have keys 'id', 'vector', 'text', 'metadata'
print(f"{id}: {doc['text']}")
else:
break
Delete Documents:
.. code-block:: python
Expand Down

0 comments on commit 76d3275

Please # to comment.