def get_data_model(
    base: Type,
    index_name: str,
    schema_name: str,
    hybrid_search: bool,
    text_search_config: str,
    cache_okay: bool,
    embed_dim: int = 1536,
    use_jsonb: bool = False,
    use_halfvec: bool = False,
    indexed_metadata_keys: Optional[Set[Tuple[str, PGType]]] = None,
) -> Any:
    """
    This part create a dynamic sqlalchemy model with a new table.
    """
    from pgvector.sqlalchemy import Vector
    from sqlalchemy import Column, Computed
    from sqlalchemy.dialects.postgresql import (
        BIGINT,
        JSON,
        JSONB,
        TSVECTOR,
        VARCHAR,
        UUID,
        DOUBLE_PRECISION,
    )
    from sqlalchemy import cast, column
    from sqlalchemy import String, Integer, Numeric, Float, Boolean, Date, DateTime
    from sqlalchemy.schema import Index
    from sqlalchemy.types import TypeDecorator

    pg_type_map = {
        "text": String,
        "int": Integer,
        "integer": Integer,
        "numeric": Numeric,
        "float": Float,
        "double precision": DOUBLE_PRECISION,  # or Float(precision=53)
        "boolean": Boolean,
        "date": Date,
        "timestamp": DateTime,
        "uuid": UUID,
    }

    indexed_metadata_keys = indexed_metadata_keys or set()
    # check that types are in pg_type_map
    for key, pg_type in indexed_metadata_keys:
        if pg_type not in pg_type_map:
            raise ValueError(
                f"Invalid type {pg_type} for key {key}. "
                f"Must be one of {list(pg_type_map.keys())}"
            )

    class TSVector(TypeDecorator):
        impl = TSVECTOR
        cache_ok = cache_okay

    tablename = "data_%s" % index_name  # dynamic table name
    class_name = "Data%s" % index_name  # dynamic class name
    indexname = "%s_idx" % index_name  # dynamic class name

    metadata_dtype = JSONB if use_jsonb else JSON

    if use_halfvec:
        embedding_col = Column(HALFVEC(embed_dim))  # type: ignore
    else:
        embedding_col = Column(Vector(embed_dim))  # type: ignore

    metadata_indices = [
        Index(
            f"{indexname}_{key}_{pg_type.replace(' ', '_')}",
            cast(column("metadata_").op("->>")(key), pg_type_map[pg_type]),
            postgresql_using="btree",
        )
        for key, pg_type in indexed_metadata_keys
    ]

    if hybrid_search:

        class HybridAbstractData(base):  # type: ignore
            __abstract__ = True  # this line is necessary
            id = Column(BIGINT, primary_key=True, autoincrement=True)
            text = Column(VARCHAR, nullable=False)
            metadata_ = Column(metadata_dtype)
            node_id = Column(VARCHAR)
            embedding = embedding_col
            text_search_tsv = Column(  # type: ignore
                TSVector(),
                Computed(
                    "to_tsvector('%s', text)" % text_search_config, persisted=True
                ),
            )

        model = type(
            class_name,
            (HybridAbstractData,),
            {
                "__tablename__": tablename,
                "__table_args__": (*metadata_indices, {"schema": schema_name}),
            },
        )

        Index(
            indexname,
            model.text_search_tsv,  # type: ignore
            postgresql_using="gin",
        )
        Index(
            f"{indexname}_1",
            model.metadata_["ref_doc_id"].astext,  # type: ignore
            postgresql_using="btree",
        )
    else:

        class AbstractData(base):  # type: ignore
            __abstract__ = True  # this line is necessary
            id = Column(BIGINT, primary_key=True, autoincrement=True)
            text = Column(VARCHAR, nullable=False)
            metadata_ = Column(metadata_dtype)
            node_id = Column(VARCHAR)
            embedding = embedding_col

        model = type(
            class_name,
            (AbstractData,),
            {
                "__tablename__": tablename,
                "__table_args__": (*metadata_indices, {"schema": schema_name}),
            },
        )

        Index(
            f"{indexname}_1",
            model.metadata_["ref_doc_id"].astext,  # type: ignore
            postgresql_using="btree",
        )

    return model

    This part create a dynamic sqlalchemy model with a new table.
    
llama-index-integrations/vector_stores/llama-index-vector-stores-postgres/llama_index/vector_stores/postgres/base.py