-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
LlamaIndexRetriever imports not working since Llamaindex v0.10 #17860
Comments
🤖 It's great that you've identified a potential solution to the import issues after updating to LlamaIndex v0.10. Your proposed changes to the imports in the LlamaIndexRetriever class seem reasonable. I encourage you to go ahead and create a pull request with your proposed changes. Your contribution will be valuable in resolving this issue for the community. Thank you for your willingness to help improve the repository!
|
- **Description:** Fixing outdated imports after v0.10 llama index update and updating metadata and source text access - **Issue:** #17860 - **Twitter handle:** @maximeperrin_ --------- Co-authored-by: Maxime Perrin <mperrin@doing.fr>
…n-ai#17870) - **Description:** Fixing outdated imports after v0.10 llama index update and updating metadata and source text access - **Issue:** langchain-ai#17860 - **Twitter handle:** @maximeperrin_ --------- Co-authored-by: Maxime Perrin <mperrin@doing.fr>
…n-ai#17870) - **Description:** Fixing outdated imports after v0.10 llama index update and updating metadata and source text access - **Issue:** langchain-ai#17860 - **Twitter handle:** @maximeperrin_ --------- Co-authored-by: Maxime Perrin <mperrin@doing.fr>
…n-ai#17870) - **Description:** Fixing outdated imports after v0.10 llama index update and updating metadata and source text access - **Issue:** langchain-ai#17860 - **Twitter handle:** @maximeperrin_ --------- Co-authored-by: Maxime Perrin <mperrin@doing.fr>
…n-ai#17870) - **Description:** Fixing outdated imports after v0.10 llama index update and updating metadata and source text access - **Issue:** langchain-ai#17860 - **Twitter handle:** @maximeperrin_ --------- Co-authored-by: Maxime Perrin <mperrin@doing.fr>
still get this error with File "/usr/src/app/pages/search_lang.py", line 109, in main langchain 0.1.16 |
Checked other resources
Example Code
`
from llama_index.vector_stores.milvus import MilvusVectorStore
from langchain_community.retrievers.llama_index import LlamaIndexRetriever
from llama_index.core.indices.vector_store.base import VectorStoreIndex
vector_store = MilvusVectorStore(dim=1536)
retriever = LlamaIndexRetriever(index=VectorStoreIndex.from_vector_store(vector_store))
`
Error Message and Stack Trace (if applicable)
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 123, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in call
raise exc
File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in call
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
raise exc
File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 758, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 778, in app
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 299, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 79, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
raise exc
File "/usr/local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 77, in app
await response(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/sse_starlette/sse.py", line 255, in call
async with anyio.create_task_group() as task_group:
File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 597, in aexit
raise exceptions[0]
File "/usr/local/lib/python3.11/site-packages/sse_starlette/sse.py", line 258, in wrap
await func()
File "/usr/local/lib/python3.11/site-packages/sse_starlette/sse.py", line 245, in stream_response
async for data in self.body_iterator:
File "/usr/local/lib/python3.11/site-packages/langserve/api_handler.py", line 1056, in _stream_log
async for chunk in self._runnable.astream_log(
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 686, in astream_log
async for item in _astream_log_implementation( # type: ignore
File "/usr/local/lib/python3.11/site-packages/langchain_core/tracers/log_stream.py", line 612, in _astream_log_implementation
await task
File "/usr/local/lib/python3.11/site-packages/langchain_core/tracers/log_stream.py", line 566, in consume_astream
async for chunk in runnable.astream(input, config, **kwargs):
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 4144, in astream
async for item in self.bound.astream(
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 4144, in astream
async for item in self.bound.astream(
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2449, in astream
async for chunk in self.atransform(input_aiter(), config, **kwargs):
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2432, in atransform
async for chunk in self._atransform_stream_with_config(
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1595, in _atransform_stream_with_config
chunk: Output = await asyncio.create_task( # type: ignore[call-arg]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/tracers/log_stream.py", line 237, in tap_output_aiter
async for chunk in output:
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2402, in _atransform
async for output in final_pipeline:
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 4180, in atransform
async for item in self.bound.atransform(
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2432, in atransform
async for chunk in self._atransform_stream_with_config(
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1595, in _atransform_stream_with_config
chunk: Output = await asyncio.create_task( # type: ignore[call-arg]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/tracers/log_stream.py", line 237, in tap_output_aiter
async for chunk in output:
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2402, in _atransform
async for output in final_pipeline:
File "/usr/local/lib/python3.11/site-packages/langchain_core/output_parsers/transform.py", line 60, in atransform
async for chunk in self._atransform_stream_with_config(
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1560, in _atransform_stream_with_config
final_input: Optional[Input] = await py_anext(input_for_tracing, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/utils/aiter.py", line 62, in anext_impl
return await anext(iterator)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/utils/aiter.py", line 97, in tee_peer
item = await iterator.anext()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/configurable.py", line 218, in atransform
async for chunk in runnable.atransform(input, config, **kwargs):
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1061, in atransform
async for chunk in input:
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1061, in atransform
async for chunk in input:
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2862, in atransform
async for chunk in self._atransform_stream_with_config(
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1595, in _atransform_stream_with_config
chunk: Output = await asyncio.create_task( # type: ignore[call-arg]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/tracers/log_stream.py", line 237, in tap_output_aiter
async for chunk in output:
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2849, in _atransform
chunk = AddableDict({step_name: task.result()})
^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2832, in get_next_chunk
return await py_anext(generator)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2432, in atransform
async for chunk in self._atransform_stream_with_config(
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1595, in _atransform_stream_with_config
chunk: Output = await asyncio.create_task( # type: ignore[call-arg]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/tracers/log_stream.py", line 237, in tap_output_aiter
async for chunk in output:
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2402, in _atransform
async for output in final_pipeline:
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 3711, in atransform
async for output in self._atransform_stream_with_config(
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1560, in _atransform_stream_with_config
final_input: Optional[Input] = await py_anext(input_for_tracing, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/utils/aiter.py", line 62, in anext_impl
return await anext(iterator)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/utils/aiter.py", line 97, in tee_peer
item = await iterator.anext()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1071, in atransform
async for output in self.astream(final, config, **kwargs):
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 592, in astream
yield await self.ainvoke(input, config, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/retrievers.py", line 137, in ainvoke
return await self.aget_relevant_documents(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/retrievers.py", line 280, in aget_relevant_documents
raise e
File "/usr/local/lib/python3.11/site-packages/langchain_core/retrievers.py", line 273, in aget_relevant_documents
result = await self._aget_relevant_documents(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/retrievers.py", line 168, in _aget_relevant_documents
return await run_in_executor(
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_core/runnables/config.py", line 493, in run_in_executor
return await asyncio.get_running_loop().run_in_executor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/langchain_community/retrievers/llama_index.py", line 28, in _get_relevant_documents
raise ImportError(
ImportError: You need to install
pip install llama-index
to use this retriever.Description
Since LlamaIndex v0.10, packages structure is different. You might have to change these imports for LlamaIndexRetriever class in langchain_community.retrievers.llama_index:
from llama_index.core.indices.base import BaseGPTIndex from llama_index.core.base.response.schema import Response
to
from llama_index.core.indices.base import BaseGPTIndex from llama_index.core.base.response.schema import Response
**NOTE : ** This might not be the only import problem since the new Llama index update
System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found:
The text was updated successfully, but these errors were encountered: