langchain-ai / web-explorer

356 stars 83 forks source link

AssertionError #11

Closed moabdelmoez closed 8 months ago

moabdelmoez commented 8 months ago

Hello All,

I have ran the app successfully but I got this AssertionError Message, Can you help us on this please?

Error Message; WARNING:langchain.callbacks.manager:Error in PrintRetrievalHandler.on_retriever_start callback: PrintRetrievalHandler.on_retriever_start() takes 2 positional arguments but 3 were given INFO:langchain.retrievers.web_research:Generating questions for Google Search ... INFO:langchain.retrievers.web_research:Questions for Google Search (raw): {'question': 'Central Park', 'text': LineList(lines=['1. What are the top attractions to visit in Central Park?\n', '2. How big is Central Park and what are its boundaries?\n'])} INFO:langchain.retrievers.web_research:Questions for Google Search: ['1. What are the top attractions to visit in Central Park?\n', '2. How big is Central Park and what are its boundaries?\n'] INFO:langchain.retrievers.web_research:Searching for relevat urls ... INFO:langchain.retrievers.web_research:Searching for relevat urls ... INFO:langchain.retrievers.web_research:Search results: [{'title': "Visiting New York's Central Park: 14 Top Attractions | PlanetWare", 'link': 'https://www.planetware.com/new-york-city/new-york-central-park-us-ny-central.htm', 'snippet': 'Apr 14, 2023 ... 1. Belvedere Castle · 2. Central Park Zoo · 3. Strawberry Fields · 4. Bethesda Fountain and Terrace · 5. Conservatory Garden · 6. Loeb Boathouse on\xa0...'}, {'title': 'Top 10 Attractions In Central Park - Central Park', 'link': 'https://centralpark.org/top-10-places-in-central-park/', 'snippet': '10. Conservatory Water · 9. Wollman Rink · 8. Imagine Mosaic – Strawberry Fields · 7. Conservatory Garden · 6. Central Park Reservoir · 5. Bow Bridge · 4. Bethesda\xa0...'}, {'title': 'What are the best places to see and visit in Central Park?', 'link': 'https://www.centralparktours.net/blog/what-are-the-best-places-in-central-park/', 'snippet': 'Apr 17, 2020 ... Top spots in Central Park that are worthy visiting · The Great Lawn · Conservatory Garden · Belvedere Castle · Carousel · Alice in Wonderland.'}] INFO:langchain.retrievers.web_research:Searching for relevat urls ... INFO:langchain.retrievers.web_research:Search results: [{'title': 'Central Park - Wikipedia', 'link': 'https://en.wikipedia.org/wiki/Central_Park', 'snippet': "Its size and cultural position make it a model for the world's urban parks. Its influence earned Central Park the designations of National Historic Landmark in\xa0..."}, {'title': 'Transform Plate Boundaries - Geology (U.S. National Park Service)', 'link': 'https://www.nps.gov/subjects/geology/plate-tectonics-transform-plate-boundaries.htm', 'snippet': 'Feb 11, 2020 ... A transform plate boundary developed where the Pacific Plate was in contact with the North American Plate and the volcanism ceased in central\xa0...'}, {'title': 'Harlem - Wikipedia', 'link': 'https://en.wikipedia.org/wiki/Harlem', 'snippet': '... boundaries, regarding only central Harlem as part of Harlem proper. ... This section is bounded by Fifth Avenue on the east; Central Park on the south;\xa0...'}] INFO:langchain.retrievers.web_research:New URLs to load: ['https://centralpark.org/top-10-places-in-central-park/', 'https://www.centralparktours.net/blog/what-are-the-best-places-in-central-park/', 'https://en.wikipedia.org/wiki/Central_Park', 'https://www.nps.gov/subjects/geology/plate-tectonics-transform-plate-boundaries.htm', 'https://www.planetware.com/new-york-city/new-york-central-park-us-ny-central.htm', 'https://en.wikipedia.org/wiki/Harlem'] INFO:langchain.retrievers.web_research:Indexing new urls... Fetching pages: 100%|################################################################################################################################| 6/6 [00:06<00:00, 1.10s/it] 2023-10-22 17:26:45.320 Uncaught app exception Traceback (most recent call last): File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 541, in _run_script exec(code, module.__dict__) File "/Users/mostafa/Downloads/web-LLM-app/web-explorer/web_explorer.py", line 103, in <module> result = qa_chain({"question": question},callbacks=[retrieval_streamer_cb, stream_handler]) File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/langchain/chains/base.py", line 243, in __call__ raise e File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/langchain/chains/base.py", line 237, in __call__ self._call(inputs, run_manager=run_manager) File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/langchain/chains/qa_with_sources/base.py", line 141, in _call docs = self._get_docs(inputs, run_manager=_run_manager) File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/langchain/chains/qa_with_sources/retrieval.py", line 51, in _get_docs docs = self.retriever.get_relevant_documents( File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/langchain/schema/retriever.py", line 181, in get_relevant_documents raise e File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/langchain/schema/retriever.py", line 174, in get_relevant_documents result = self._get_relevant_documents( File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/langchain/retrievers/web_research.py", line 205, in _get_relevant_documents self.vectorstore.add_documents(docs) File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/langchain/vectorstores/base.py", line 104, in add_documents return self.add_texts(texts, metadatas, **kwargs) File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/langchain/vectorstores/faiss.py", line 153, in add_texts return self.__add(texts, embeddings, metadatas=metadatas, ids=ids, **kwargs) File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/langchain/vectorstores/faiss.py", line 120, in __add self.index.add(vector) File "/Users/mostafa/Downloads/web-LLM-app/venv-web/lib/python3.10/site-packages/faiss/class_wrappers.py", line 228, in replacement_add assert d == self.d AssertionError

moabdelmoez commented 8 months ago

@hwchase17 appreciate your help here, please

moabdelmoez commented 8 months ago

The problem was that the embeddings model you were using was from OpenAI, but I am now using a hugging face embedding model (Sentence Transformers). By default, the pretrained models output embeddings with size 768 (base-models) or with size 1024 (large-models).