Skip to content

Unable to declare a Vector-Field for a JsonModel #656

Open
@MarkusPorti

Description

@MarkusPorti

The Bug

I'm trying to declare a Field as a Vector-Field by setting the vector_options on the Field.
Pydantic is then forcing me to annotate the field with a proper type.
But with any possible type for a vector, I always get errors.

The one that I think should definitly work is list[float], but this results in
AttributeError: type object 'float' has no attribute '__origin__'.

Example

class Group(JsonModel):
    articles: List[Article]
    tender_text: str = Field(index=False)
    tender_embedding: list[float] = Field(
        index=True,
        vector_options=VectorFieldOptions(
            algorithm=VectorFieldOptions.ALGORITHM.FLAT,
            type=VectorFieldOptions.TYPE.FLOAT32,
            dimension=3,
            distance_metric=VectorFieldOptions.DISTANCE_METRIC.COSINE
        ))

No Documentation for Vector-Fields?

There seems to be no documentation about this feature.
I just found a merge-request which describes some features a bit, but there is no example, test or any documentation about this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions