Skip to content

Commit

Permalink
community[patch]: ElasticsearchStore: preserve user headers (langchai…
Browse files Browse the repository at this point in the history
…n-ai#16830)

Users can provide an Elasticsearch connection with custom headers. This
PR makes sure these headers are preserved when adding the langchain user
agent header.
  • Loading branch information
maxjakob authored and Hayden Wolff committed Feb 27, 2024
1 parent 2e104cf commit 81e0008
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,9 @@ def __init__(
self.strategy = strategy

if es_connection is not None:
self.client = es_connection.options(
headers={"user-agent": self.get_user_agent()}
)
headers = dict(es_connection._headers)
headers.update({"user-agent": self.get_user_agent()})
self.client = es_connection.options(headers=headers)
elif es_url is not None or es_cloud_id is not None:
self.client = ElasticsearchStore.connect_to_elasticsearch(
es_url=es_url,
Expand Down

0 comments on commit 81e0008

Please sign in to comment.