You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to convert the Notion QA example to use ES but I can't seem to get it to work.
Here's the code:
parser = argparse.ArgumentParser(description='Ask a question to the notion DB.')
parser.add_argument('question', type=str, help='The question to ask the notion DB')
args = parser.parse_args()
# Load the LangChain.
# index = faiss.read_index("docs.index")
# with open("faiss_store.pkl", "rb") as f:
# store = pickle.load(f)
embeddings = OpenAIEmbeddings()
# store.index = index
store = ElasticVectorSearch(
"http://localhost:9200",
"embeddings",
embeddings.embed_query
)
chain = VectorDBQAWithSourcesChain.from_llm(llm=OpenAI(temperature=0), vectorstore=store)
result = chain({"question": args.question})
print(f"Answer: {result['answer']}")
print(f"Sources: {result['sources']}")
And here's the error:
Traceback (most recent call last):
File "/Users/chintan/Dropbox/Projects/notion-qa/qa.py", line 34, in <module>
result = chain({"question": args.question})
File "/usr/local/lib/python3.9/site-packages/langchain/chains/base.py", line 146, in __call__
raise e
File "/usr/local/lib/python3.9/site-packages/langchain/chains/base.py", line 142, in __call__
outputs = self._call(inputs)
File "/usr/local/lib/python3.9/site-packages/langchain/chains/qa_with_sources/base.py", line 96, in _call
docs = self._get_docs(inputs)
File "/usr/local/lib/python3.9/site-packages/langchain/chains/qa_with_sources/vector_db.py", line 20, in _get_docs
return self.vectorstore.similarity_search(question, k=self.k)
File "/usr/local/lib/python3.9/site-packages/langchain/vectorstores/elastic_vector_search.py", line 121, in similarity_search
response = self.client.search(index=self.index_name, query=script_query)
File "/usr/local/lib/python3.9/site-packages/elasticsearch/client/utils.py", line 152, in _wrapped
return func(*args, params=params, headers=headers, **kwargs)
TypeError: search() got an unexpected keyword argument 'query'
It feels like it could be an ES version issue? Specifically, this seems to be what's erroring out - the ES client doesn't want to accept query as a valid param:
File "/usr/local/lib/python3.9/site-packages/langchain/vectorstores/elastic_vector_search.py", line 121, in similarity_search
response = self.client.search(index=self.index_name, query=script_query)
Sure enough, when I look at the source code for the search method in the client, I see:
Hi, @chintanparikh. I'm helping the LangChain team manage their backlog and I wanted to let you know that we are marking this issue as stale. From what I understand, you opened this issue regarding the ElasticSearch client not accepting the 'query' parameter. It seems like you were seeking advice on how to resolve this, possibly due to a version issue with ElasticSearch. Since there hasn't been any activity or comments on the issue, we wanted to check if it is still relevant to the latest version of the LangChain repo. If you respond to this, the LangChain team will be notified to take a look. Otherwise, the issue will be automatically closed in 7 days. Thank you!
dosubotbot
added
the
stale
Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed
label
Aug 15, 2023
I'm trying to convert the Notion QA example to use ES but I can't seem to get it to work.
Here's the code:
And here's the error:
It feels like it could be an ES version issue? Specifically, this seems to be what's erroring out - the ES client doesn't want to accept
query
as a valid param:Sure enough, when I look at the source code for the
search
method in the client, I see:which seems to be expecting a
body
instead of aquery
parameter. This is where I got stuck - would love any advice.The text was updated successfully, but these errors were encountered: