assafelovic / gpt-researcher

GPT based autonomous agent that does online comprehensive research on any given topic
https://gptr.dev
MIT License
13.05k stars 1.61k forks source link

TypeError: unsupported operand type(s) for -: 'int' and 'simsimd.DistancesTensor' #493

Open ockiphertweck opened 1 month ago

ockiphertweck commented 1 month ago

ERROR: Exception in ASGI application ....... research_result = await researcher.conduct_research() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/gpt_researcher/master/agent.py", line 85, in conduct_research self.context = await self.get_context_by_search(self.query) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/gpt_researcher/master/agent.py", line 158, in get_context_by_search context = await asyncio.gather(*[self.process_sub_query(sub_query) for sub_query in sub_queries]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/gpt_researcher/master/agent.py", line 174, in process_sub_query content = await self.get_similar_content_by_query(sub_query, scraped_sites) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/gpt_researcher/master/agent.py", line 226, in get_similar_content_by_query return context_compressor.get_context(query, max_results=8) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/gpt_researcher/context/compression.py", line 43, in get_context relevant_docs = compressed_docs.invoke(query) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/langchain_core/retrievers.py", line 194, in invoke return self.get_relevant_documents( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/langchain_core/_api/deprecation.py", line 148, in warning_emitting_wrapper return wrapped(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/langchain_core/retrievers.py", line 323, in get_relevant_documents raise e File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/langchain_core/retrievers.py", line 316, in get_relevant_documents result = self._get_relevant_documents( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/langchain/retrievers/contextual_compression.py", line 48, in _get_relevant_documents compressed_docs = self.base_compressor.compress_documents( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/langchain/retrievers/document_compressors/base.py", line 39, in compress_documents documents = _transformer.compress_documents( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/langchain/retrievers/document_compressors/embeddings_filter.py", line 61, in compress_documents similarity = self.similarity_fn([embedded_query], embedded_documents)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/philipp/Library/Caches/pypoetry/virtualenvs/backend-xXYcI_nD-py3.11/lib/python3.11/site-packages/langchain_community/utils/math.py", line 29, in cosine_similarity Z = 1 - simd.cdist(X, Y, metric="cosine") ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TypeError: unsupported operand type(s) for -: 'int' and 'simsimd.DistancesTen

I am getting the error above when running the ".conduct_research()" function.

I am using the pip package in version 0.4.0.

I am using the FastAPI example

assafelovic commented 1 month ago

Hey @ockiphertweck is this happening always or for specific queries? If so can you please share more information about your query?

ockiphertweck commented 1 month ago

Hi @assafelovic at least for the queries below, the error occurs. The step that is executed always prints the following in the logs : 📝 Getting relevant content based on query: .....

query: "LLM in Science" report_type: "research_report"

query: "what team may win the NBA finals?" report_type: "research_report"

assafelovic commented 1 month ago

Hey @ockiphertweck have tested all queries and works fine on my end. Have you tried running with the local UI to see if it works? Can you please share the entire code snippet you're trying to run?

ockiphertweck commented 1 month ago

Hey @assafelovic hmm that is strange. Using the docker image, everything was working. The code I used is the following:

from gpt_researcher import GPTResearcher
@router.get("/report/{report_type}")
async def get_report(query: str, report_type: str) -> dict:
    researcher = GPTResearcher(query, report_type)
    research_result = await researcher.conduct_research()
    report = await researcher.write_report()
    return {"report": report}

Then I use the SwaggerUI for making the request.

Just updated the package to version 0.4.5 and still getting the same error.

assafelovic commented 3 weeks ago

Not aware of SwaggerUI @ockiphertweck . ANy update on this?