mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
feat(module): add param ids to ElasticVectorSearch.from_texts method (#7425)
# add param ids to ElasticVectorSearch.from_texts method. - Description: add param ids to ElasticVectorSearch.from_texts method. - Issue: NA. It seems `add_texts` already supports passing in document ids, but param `ids` is omitted in `from_texts` classmethod, - Dependencies: None, - Tag maintainer: @rlancemartin, @eyurtsev please have a look, thanks ``` # ElasticVectorSearch add_texts def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, refresh_indices: bool = True, ids: Optional[List[str]] = None, **kwargs: Any, ) -> List[str]: ... ``` ``` # ElasticVectorSearch from_texts @classmethod def from_texts( cls, texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, elasticsearch_url: Optional[str] = None, index_name: Optional[str] = None, refresh_indices: bool = True, **kwargs: Any, ) -> ElasticVectorSearch: ``` Co-authored-by: charosen <charosen@bupt.cn>
This commit is contained in:
parent
a5fd8873b1
commit
50a9fcccb0
@ -157,8 +157,8 @@ class ElasticVectorSearch(VectorStore, ABC):
|
||||
self,
|
||||
texts: Iterable[str],
|
||||
metadatas: Optional[List[dict]] = None,
|
||||
refresh_indices: bool = True,
|
||||
ids: Optional[List[str]] = None,
|
||||
refresh_indices: bool = True,
|
||||
**kwargs: Any,
|
||||
) -> List[str]:
|
||||
"""Run more texts through the embeddings and add to the vectorstore.
|
||||
@ -166,6 +166,7 @@ class ElasticVectorSearch(VectorStore, ABC):
|
||||
Args:
|
||||
texts: Iterable of strings to add to the vectorstore.
|
||||
metadatas: Optional list of metadatas associated with the texts.
|
||||
ids: Optional list of unique IDs.
|
||||
refresh_indices: bool to refresh ElasticSearch indices
|
||||
|
||||
Returns:
|
||||
@ -260,6 +261,7 @@ class ElasticVectorSearch(VectorStore, ABC):
|
||||
texts: List[str],
|
||||
embedding: Embeddings,
|
||||
metadatas: Optional[List[dict]] = None,
|
||||
ids: Optional[List[str]] = None,
|
||||
elasticsearch_url: Optional[str] = None,
|
||||
index_name: Optional[str] = None,
|
||||
refresh_indices: bool = True,
|
||||
@ -292,7 +294,7 @@ class ElasticVectorSearch(VectorStore, ABC):
|
||||
index_name = index_name or uuid.uuid4().hex
|
||||
vectorsearch = cls(elasticsearch_url, index_name, embedding, **kwargs)
|
||||
vectorsearch.add_texts(
|
||||
texts, metadatas=metadatas, refresh_indices=refresh_indices
|
||||
texts, metadatas=metadatas, ids=ids, refresh_indices=refresh_indices
|
||||
)
|
||||
return vectorsearch
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user