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

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

Open
ockiphertweck opened this issue May 11, 2024 · 4 comments

Comments

@ockiphertweck
Copy link

ockiphertweck commented May 11, 2024

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
Copy link
Owner

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

@ockiphertweck
Copy link
Author

ockiphertweck commented May 12, 2024

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
Copy link
Owner

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
Copy link
Author

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.

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

2 participants