add LanceModel to docs (#386)

Co-authored-by: Chang She <chang@lancedb.com>
This commit is contained in:
Chang She
2023-07-31 15:12:02 -04:00
committed by GitHub
parent b06e214d29
commit 4b45128bd6
3 changed files with 7 additions and 2 deletions

View File

@@ -3,7 +3,6 @@
[Pydantic](https://docs.pydantic.dev/latest/) is a data validation library in Python.
LanceDB integrates with Pydantic for schema inference, data ingestion, and query result casting.
## Schema
LanceDB supports to create Apache Arrow Schema from a

View File

@@ -56,4 +56,4 @@ pip install lancedb
::: lancedb.pydantic.vector
::: lancedb.pydantic.LanceModel

View File

@@ -275,10 +275,16 @@ class LanceModel(pydantic.BaseModel):
@classmethod
def to_arrow_schema(cls):
"""
Get the Arrow Schema for this model.
"""
return pydantic_to_schema(cls)
@classmethod
def field_names(cls) -> List[str]:
"""
Get the field names of this model.
"""
if PYDANTIC_VERSION.major < 2:
return list(cls.__fields__.keys())
return list(cls.model_fields.keys())