mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 14:43:07 +00:00
linting
This commit is contained in:
@@ -163,6 +163,7 @@ class BaseIndex(Generic[T]):
|
||||
for item_batch in batch_iterate(batch_size, items):
|
||||
yield self.upsert(item_batch, **kwargs)
|
||||
|
||||
@abc.abstractmethod
|
||||
@beta(message="Added in 0.2.15. The API is subject to change.")
|
||||
def upsert(self, items: Sequence[T], /, **kwargs: Any) -> UpsertResponse:
|
||||
"""Upsert items into the index.
|
||||
@@ -270,11 +271,8 @@ class BaseIndex(Generic[T]):
|
||||
|
||||
@abc.abstractmethod
|
||||
def delete(
|
||||
self,
|
||||
ids: Sequence[str],
|
||||
/,
|
||||
**kwargs: Any,
|
||||
) -> Union[DeleteResponse, bool]:
|
||||
self, ids: Optional[List[str]] = None, **kwargs: Any
|
||||
) -> Union[DeleteResponse, bool, None]:
|
||||
"""Delete by IDs or other criteria.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -54,7 +54,7 @@ if TYPE_CHECKING:
|
||||
AsyncCallbackManagerForRetrieverRun,
|
||||
CallbackManagerForRetrieverRun,
|
||||
)
|
||||
from langchain_core.indexing.base import UpsertResponse
|
||||
from langchain_core.indexing.base import DeleteResponse, UpsertResponse
|
||||
|
||||
from langchain_core.documents.base import Document
|
||||
from langchain_core.indexing import BaseIndex
|
||||
@@ -235,8 +235,10 @@ class VectorStore(BaseIndex[Document]):
|
||||
)
|
||||
return None
|
||||
|
||||
def delete(self, ids: Optional[List[str]] = None, **kwargs: Any) -> Optional[bool]:
|
||||
"""Delete by vector ID or other criteria.
|
||||
def delete(
|
||||
self, ids: Optional[List[str]] = None, **kwargs: Any
|
||||
) -> Union[DeleteResponse, None, bool]:
|
||||
"""Delete by ID or other criteria.
|
||||
|
||||
Args:
|
||||
ids: List of ids to delete.
|
||||
@@ -249,7 +251,7 @@ class VectorStore(BaseIndex[Document]):
|
||||
|
||||
raise NotImplementedError("delete method must be implemented by subclass.")
|
||||
|
||||
def get_by_ids(self, ids: Sequence[str], /) -> List[Document]:
|
||||
def get_by_ids(self, ids: Sequence[str], /, **kwargs: Any) -> List[Document]:
|
||||
"""Get documents by their IDs.
|
||||
|
||||
The returned documents are expected to have the ID field set to the ID of the
|
||||
@@ -267,6 +269,7 @@ class VectorStore(BaseIndex[Document]):
|
||||
|
||||
Args:
|
||||
ids: List of ids to retrieve.
|
||||
kwargs: Other keyword arguments these are up to the implementation.
|
||||
|
||||
Returns:
|
||||
List of Documents.
|
||||
@@ -278,7 +281,7 @@ class VectorStore(BaseIndex[Document]):
|
||||
)
|
||||
|
||||
# Implementations should override this method to provide an async native version.
|
||||
async def aget_by_ids(self, ids: Sequence[str], /) -> List[Document]:
|
||||
async def aget_by_ids(self, ids: Sequence[str], /, **kwargs: Any) -> List[Document]:
|
||||
"""Get documents by their IDs.
|
||||
|
||||
The returned documents are expected to have the ID field set to the ID of the
|
||||
@@ -296,6 +299,7 @@ class VectorStore(BaseIndex[Document]):
|
||||
|
||||
Args:
|
||||
ids: List of ids to retrieve.
|
||||
kwargs: Other keyword arguments these are up to the implementation.
|
||||
|
||||
Returns:
|
||||
List of Documents.
|
||||
@@ -306,8 +310,8 @@ class VectorStore(BaseIndex[Document]):
|
||||
|
||||
async def adelete(
|
||||
self, ids: Optional[List[str]] = None, **kwargs: Any
|
||||
) -> Optional[bool]:
|
||||
"""Delete by vector ID or other criteria.
|
||||
) -> Union[DeleteResponse, None, bool]:
|
||||
"""Delete by ID or other criteria.
|
||||
|
||||
Args:
|
||||
ids: List of ids to delete.
|
||||
|
||||
@@ -73,7 +73,7 @@ class InMemoryVectorStore(VectorStore):
|
||||
"failed": [],
|
||||
}
|
||||
|
||||
def get_by_ids(self, ids: Sequence[str], /) -> List[Document]:
|
||||
def get_by_ids(self, ids: Sequence[str], /, **kwargs: Any) -> List[Document]:
|
||||
"""Get documents by their ids."""
|
||||
documents = []
|
||||
|
||||
@@ -89,7 +89,7 @@ class InMemoryVectorStore(VectorStore):
|
||||
)
|
||||
return documents
|
||||
|
||||
async def aget_by_ids(self, ids: Sequence[str], /) -> List[Document]:
|
||||
async def aget_by_ids(self, ids: Sequence[str], /, **kwargs: Any) -> List[Document]:
|
||||
return self.get_by_ids(ids)
|
||||
|
||||
async def aadd_texts(
|
||||
|
||||
@@ -65,7 +65,7 @@ class CustomSyncVectorStore(VectorStore):
|
||||
"failed": [],
|
||||
}
|
||||
|
||||
def get_by_ids(self, ids: Sequence[str], /) -> List[Document]:
|
||||
def get_by_ids(self, ids: Sequence[str], /, **kwargs: Any) -> List[Document]:
|
||||
return [self.store[id] for id in ids if id in self.store]
|
||||
|
||||
def delete_by_ids(
|
||||
|
||||
Reference in New Issue
Block a user