Is pydantic v2 incompatible with llama-index? Multiple models such as MetadataFilters inherit from the v1 BaseModel (which cannot be used to compose a v2 model)
https://github.com/pydantic/pydantic/issues/7997E.G
This line exists in the schema file
from llama_index.core.bridge.pydantic import (
BaseModel
)
This v1 BaseModel is used in the creation of MetadataFilters exported from
llama_index.core.vector_stores
Other models that i create use the BaseModel from pydantic v2 and are composed with the existing v1 llama-index models. This throws errors. When creating our own pydantic models should we always use the BaseModel exported from pydantic.v1?
I am trying to create my own pydantic model like this
class ChatBody(BaseModel):
messages: list[OpenAIMessage]
use_context: bool = False
conversation_id: str | None = None
context_filter: MetadataFilters | None = None
include_sources: bool = True
stream: bool = False
Where the BaseModel that ChatBody inherits from is important from pydantic (v2) but MetadataFilters inherits from the BaseModel that is exported from
llama_index.core.bridge.pydantic
which is a v1 model