fix: Allow non-verified SSL connections in Elastic (#8623)
* fix: Allow non-verified SSL connections in Elastic * [autofix.ci] apply automated fixes * Update src/backend/base/langflow/components/vectorstores/elasticsearch.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update elasticsearch.py --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
This commit is contained in:
parent
412fdd20cc
commit
84e46c00ef
1 changed files with 28 additions and 0 deletions
|
|
@ -1,10 +1,12 @@
|
|||
from typing import Any
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
from langchain.schema import Document
|
||||
from langchain_elasticsearch import ElasticsearchStore
|
||||
|
||||
from langflow.base.vectorstores.model import LCVectorStoreComponent, check_cached_vector_store
|
||||
from langflow.io import (
|
||||
BoolInput,
|
||||
DropdownInput,
|
||||
FloatInput,
|
||||
HandleInput,
|
||||
|
|
@ -97,6 +99,13 @@ class ElasticsearchVectorStoreComponent(LCVectorStoreComponent):
|
|||
advanced=True,
|
||||
info="API Key for Elastic Cloud authentication. If used, 'username' and 'password' are not required.",
|
||||
),
|
||||
BoolInput(
|
||||
name="verify_certs",
|
||||
display_name="Verify SSL Certificates",
|
||||
value=True,
|
||||
advanced=True,
|
||||
info="Whether to verify SSL certificates when connecting to Elasticsearch.",
|
||||
),
|
||||
]
|
||||
|
||||
@check_cached_vector_store
|
||||
|
|
@ -124,6 +133,25 @@ class ElasticsearchVectorStoreComponent(LCVectorStoreComponent):
|
|||
if self.api_key:
|
||||
es_params["api_key"] = self.api_key
|
||||
|
||||
# Check if we need to verify SSL certificates
|
||||
if self.verify_certs is False:
|
||||
# Build client parameters for Elasticsearch constructor
|
||||
client_params: dict[str, Any] = {}
|
||||
client_params["verify_certs"] = False
|
||||
|
||||
if self.cloud_id:
|
||||
client_params["cloud_id"] = self.cloud_id
|
||||
else:
|
||||
client_params["hosts"] = [self.elasticsearch_url]
|
||||
|
||||
if self.api_key:
|
||||
client_params["api_key"] = self.api_key
|
||||
elif self.username and self.password:
|
||||
client_params["basic_auth"] = (self.username, self.password)
|
||||
|
||||
es_client = Elasticsearch(**client_params)
|
||||
es_params["es_connection"] = es_client
|
||||
|
||||
elasticsearch = ElasticsearchStore(**es_params)
|
||||
|
||||
# If documents are provided, add them to the store
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue