From d51d323cbe9b8896531169be367996f641e20969 Mon Sep 17 00:00:00 2001 From: Jonah Rangnow <104314597+minglu7@users.noreply.github.com> Date: Thu, 27 Jun 2024 21:00:16 +0800 Subject: [PATCH 1/6] Update base.py --- .../llama_index/vector_stores/elasticsearch/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py index 4a960906ed032..4f22181b59f59 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py @@ -296,7 +296,7 @@ def add( BulkIndexError: If AsyncElasticsearch async_bulk indexing fails. """ return asyncio.get_event_loop().run_until_complete( - self.async_add(nodes, create_index_if_not_exists=create_index_if_not_exists) + self.async_add(nodes, create_index_if_not_exists=create_index_if_not_exists, **add_kwargs) ) async def async_add( From bc122b20a69f14fcd85f503d1d3590a07ac4f561 Mon Sep 17 00:00:00 2001 From: Jonah Rangnow <104314597+minglu7@users.noreply.github.com> Date: Thu, 27 Jun 2024 21:25:37 +0800 Subject: [PATCH 2/6] Update base.py --- .../llama_index/vector_stores/elasticsearch/base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py index 4f22181b59f59..2388365b8e836 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py @@ -215,6 +215,7 @@ def __init__( batch_size: int = 200, distance_strategy: Optional[DISTANCE_STRATEGIES] = "COSINE", retrieval_strategy: Optional[AsyncRetrievalStrategy] = None, + **kwargs ) -> None: nest_asyncio.apply() @@ -232,12 +233,16 @@ def __init__( distance=DistanceMetric[distance_strategy] ) - metadata_mappings = { + base_metadata_mappings = { "document_id": {"type": "keyword"}, "doc_id": {"type": "keyword"}, "ref_doc_id": {"type": "keyword"}, } + metadata_mappings = kwargs.pop('metadata_mappings', None) + if metadata_mappings: + base_metadata_mappings.update(metadata_mappings) + self._store = AsyncVectorStore( user_agent=get_user_agent(), client=es_client, From 1e1a232266c570a34f934a2d4f6762004f2bb9a5 Mon Sep 17 00:00:00 2001 From: Logan Markewich Date: Thu, 27 Jun 2024 14:27:57 -0700 Subject: [PATCH 3/6] nits --- .../vector_stores/elasticsearch/base.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py index 2388365b8e836..ab388ecc2a164 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py @@ -215,7 +215,8 @@ def __init__( batch_size: int = 200, distance_strategy: Optional[DISTANCE_STRATEGIES] = "COSINE", retrieval_strategy: Optional[AsyncRetrievalStrategy] = None, - **kwargs + metadata_mappings: Optional[Dict[str, Dict[str, str]]] = None, + **kwargs, ) -> None: nest_asyncio.apply() @@ -239,10 +240,9 @@ def __init__( "ref_doc_id": {"type": "keyword"}, } - metadata_mappings = kwargs.pop('metadata_mappings', None) - if metadata_mappings: - base_metadata_mappings.update(metadata_mappings) - + if metadata_mappings is not None: + metadata_mappings.update(base_metadata_mappings) + self._store = AsyncVectorStore( user_agent=get_user_agent(), client=es_client, @@ -301,7 +301,11 @@ def add( BulkIndexError: If AsyncElasticsearch async_bulk indexing fails. """ return asyncio.get_event_loop().run_until_complete( - self.async_add(nodes, create_index_if_not_exists=create_index_if_not_exists, **add_kwargs) + self.async_add( + nodes, + create_index_if_not_exists=create_index_if_not_exists, + **add_kwargs, + ) ) async def async_add( From 4ace5b1f9c62264c8d68f2788ef8ec13e69bcc88 Mon Sep 17 00:00:00 2001 From: Logan Markewich Date: Fri, 28 Jun 2024 14:41:07 -0700 Subject: [PATCH 4/6] one final nit --- .../llama_index/vector_stores/elasticsearch/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py index ab388ecc2a164..698be93df8bd1 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/llama_index/vector_stores/elasticsearch/base.py @@ -240,8 +240,8 @@ def __init__( "ref_doc_id": {"type": "keyword"}, } - if metadata_mappings is not None: - metadata_mappings.update(base_metadata_mappings) + metadata_mappings = metadata_mappings or {} + metadata_mappings.update(base_metadata_mappings) self._store = AsyncVectorStore( user_agent=get_user_agent(), From 3a13b402d527e5f10d8a932d694e08ea83805bbc Mon Sep 17 00:00:00 2001 From: Logan Markewich Date: Fri, 28 Jun 2024 14:41:35 -0700 Subject: [PATCH 5/6] pyprojet.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cfd35c7ce398b..0d95d013462c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ name = "llama-index" packages = [{from = "_llama-index", include = "llama_index"}] readme = "README.md" repository = "https://github.com/run-llama/llama_index" -version = "0.10.43" +version = "0.10.44" [tool.poetry.dependencies] python = ">=3.8.1,<4.0" From 18b3e33c5a1baedc379fcfaa1f1b14c1215dd0a8 Mon Sep 17 00:00:00 2001 From: Logan Markewich Date: Fri, 28 Jun 2024 14:43:40 -0700 Subject: [PATCH 6/6] vbump for realsies --- .../llama-index-vector-stores-elasticsearch/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/pyproject.toml b/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/pyproject.toml index 1f6f45f4ebf8b..d4d7a697ef149 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/pyproject.toml +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-elasticsearch/pyproject.toml @@ -27,7 +27,7 @@ exclude = ["**/BUILD"] license = "MIT" name = "llama-index-vector-stores-elasticsearch" readme = "README.md" -version = "0.2.0" +version = "0.2.1" [tool.poetry.dependencies] python = ">=3.8.1,<4.0"