Open AldebaranX opened 2 months ago
Hello, @AldebaranX! I'm here to help you with any bugs, questions, or contributions you have regarding llama-index. Let's get this sorted out together!
There is indeed an incorrect dependency set on the pydantic version in llama-index-core
0.11.2 that causes an ImportError
when using pydantic versions 2.0 to 2.6. The pyproject.toml
file specifies the dependency as pydantic = ">=2.0.0,<3.0.0"
, but the code attempts to import pydantic.v1
and falls back to pydantic
if the former is not available. This indicates that the code is not compatible with pydantic versions 2.0 to 2.6, which do not have a pydantic.v1
module [1][2].
A similar issue was discussed and resolved in a closed issue: [Feature Request]: Support Pydantic v2. The resolution involved a pull request that added compatibility for both Pydantic v1 and v2 by attempting to import pydantic.v1
and falling back to the default pydantic
import if the former is not available [3].
To resolve this issue, you may need to update to a version of llama-index-core
that includes this fix or manually adjust the imports in your local environment.
To continue talking to Dosu, mention @dosu.
I'm using pydantic 2.8.2 and do not have this SchemaError: Invalid Schema:
issue?
pydantic 2.7 works fine as well
In fact, a fresh install works fine (albeit without conda -- I don't use conda)
Bug Description
llama-index 0.11.2 installed through conda (OS is Windows 10):
conda install conda-forge::llama-index
In llama-index-core 0.11.2, the dependency on pydantic is set as:
"pydantic >=2.0.0,<3.0.0",
inHowever, when import the modules for reading documents:
from llama_index.core import SimpleDirectoryReader
from llama_index.core import Document
the error raise as:
ImportError: cannot import name 'Secret' from 'pydantic' (.....\site-packages\pydantic\__init__.py)
if using pydantic version 2.0 to 2.6.Since 'Secret' class only exists for pydantic version >2.7, this is inconsistent with the dependency defined in index.json.
Update:
When using pydantic>=2.7, SchemaError raises when importing:
from llama_index.core import SimpleDirectoryReader
Version
0.11.2
Steps to Reproduce
conda install conda-forge::llama-index=0.11.2
from llama_index.core import SimpleDirectoryReader
orfrom llama_index.core import Document
For pydantic version 2.0 to 2.6:
ImportError: cannot import name 'Secret' from 'pydantic' (.....\site-packages\pydantic\__init__.py)
For pydantic version 2.7/2.8:
Relevant Logs/Tracbacks
No response