Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use the ElasticVectorSearch store with the provided notion q-a example #829

Closed
chintanparikh opened this issue Feb 1, 2023 · 1 comment

Comments

@chintanparikh
Copy link

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:

    def search(self, body=None, index=None, doc_type=None, params=None, headers=None):

which seems to be expecting a body instead of a query parameter. This is where I got stuck - would love any advice.

@dosubot
Copy link

dosubot bot commented Aug 15, 2023

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!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Aug 15, 2023
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant