From 9fa0ad93340a350a78ce0dab202b5a450dfbfef7 Mon Sep 17 00:00:00 2001 From: Rafael Soares Date: Tue, 14 Nov 2023 18:38:48 -0300 Subject: [PATCH] add elasticsearch timeout config --- app/config.py | 1 + app/main.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/config.py b/app/config.py index 67b68f5..6d5e394 100644 --- a/app/config.py +++ b/app/config.py @@ -24,3 +24,4 @@ def __init__(self): "HUGGINGFACE_API_TOKEN", "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" ), } + self.es_timeout = os.environ.get("ELASTICSEARCH_TIMEOUT", "30") diff --git a/app/main.py b/app/main.py index 5558f05..8cb57cb 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,4 @@ +from elasticsearch import Elasticsearch from fastapi import FastAPI from langchain.embeddings import SagemakerEndpointEmbeddings, HuggingFaceHubEmbeddings from langchain.embeddings.base import Embeddings @@ -44,6 +45,9 @@ def __init__(self, config: AppConfig): index_name=config.product_index_name, embedding=self.embeddings, ) + self.vectorstore.client = Elasticsearch( + hosts=config.es_url, timeout=int(config.es_timeout) + ) self.elasticStore = ElasticsearchVectorStoreIndex(self.vectorstore) self.products_indexer = ProductsIndexer(self.elasticStore) self.products_handler = ProductsHandler(self.products_indexer)