Skip to content

Commit

Permalink
minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
epinzur committed Nov 6, 2024
1 parent b7b85a1 commit 9d6c1f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions libs/astradb/langchain_astradb/graph_vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def __init__(

self.astra_env = self.vector_store.astra_env

def get_metadata_for_insertion(self, doc: Document) -> dict[str, Any]:
def _get_metadata_for_insertion(self, doc: Document) -> dict[str, Any]:
"""Prepares the links in a document by serializing them to metadata.
Args:
Expand All @@ -346,7 +346,7 @@ def get_metadata_for_insertion(self, doc: Document) -> dict[str, Any]:
]
return metadata

def restore_links(self, doc: Document) -> Document:
def _restore_links(self, doc: Document) -> Document:
"""Restores links in a document by deserializing them from metadata.
Args:
Expand All @@ -360,7 +360,7 @@ def restore_links(self, doc: Document) -> Document:
doc.metadata.pop(self.metadata_incoming_links_key)
return doc

def get_metadata_filter(
def _get_metadata_filter(
self,
metadata: dict[str, Any] | None = None,
outgoing_link: Link | None = None,
Expand Down Expand Up @@ -446,7 +446,10 @@ def from_documents(
collection_embedding_api_key=collection_embedding_api_key,
**kwargs,
)
store.add_documents(documents, ids=ids)
if ids is None:
store.add_documents(documents)
else:
store.add_documents(documents, ids=ids)
return store

@classmethod
Expand All @@ -468,5 +471,8 @@ async def afrom_documents(
setup_mode=SetupMode.ASYNC,
**kwargs,
)
await store.aadd_documents(documents, ids=ids)
if ids is None:
await store.aadd_documents(documents)
else:
await store.aadd_documents(documents, ids=ids)
return store
2 changes: 1 addition & 1 deletion libs/astradb/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9d6c1f5

Please sign in to comment.