langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
93.7k stars 15.11k forks source link

`similarity_search` for OpenSearchVectorSearch does not pass authorization header to opensearch #3270

Closed aarora79 closed 1 year ago

aarora79 commented 1 year ago

I am able to connect to Amazon OpenSearch cluster that has a username and password and ingest embeddings into but when I do a docsearch.similarity_search it fails with a 401 unauthorized error. I am able to connect to the cluster by passing the username and password as http_auth tuple.

I verified by putting traces in opensearchpy/connection/http_urllib3.py that the authorization field in the header is indeed not being sent and so the open search cluster returns a 401 unauthorized error. Here is the trace: headers={'connection': 'keep-alive', 'content-type': 'application/json', 'user-agent': 'opensearch-py/2.2.0 (Python 3.10.8)'}

I verified that a opensearch client created in the same notebook is able to query the opensearch cluster without any problem and also that it does sent the authorization field in the HTTP header. Langchain version is 0.0.144 opensearch-py version is 2.2.0

naveentatikonda commented 1 year ago

@aarora79 Thank you for creating this github issue. Will check and get back to you.

yunfeilu92 commented 1 year ago

potential fix as following https://github.com/hwchase17/langchain/pull/3416

aarora79 commented 1 year ago

Verified that this was fixed in 0.0.149.

dosubot[bot] commented 1 year ago

Hi, @aarora79. I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, the issue you reported was regarding the similarity_search function in OpenSearchVectorSearch not passing the authorization header to the OpenSearch cluster, resulting in a 401 unauthorized error. It seems that a potential fix has been suggested in a pull request, and you have verified that the issue was resolved in version 0.0.149.

Before we close this issue, we wanted to confirm if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your contribution to the LangChain repository!