Class AlloyDBModelManager (0.17.0)

AlloyDBModelManager(
    key: object, engine: langchain_google_alloydb_pg.engine.AlloyDBEngine
)

Manage models to be used with google_ml_integration Extension. Refer to Model Endpoint Management.

Methods

AlloyDBModelManager

AlloyDBModelManager(
    key: object, engine: langchain_google_alloydb_pg.engine.AlloyDBEngine
)

AlloyDBModelManager constructor.

Parameter
Name Description
engine AlloyDBEngine

Connection pool engine for managing connections to Postgres database.

__acreate_model

__acreate_model(
    model_id: str,
    model_provider: str,
    model_type: str,
    model_qualified_name: str,
    **kwargs: dict[str, str]
) -> None

Creates a registration for custom text model.

Parameters
Name Description
model_id str

A unique ID for the model endpoint that you define.

model_provider str

The provider of the model endpoint.

model_type str

The model type. Either text_embedding or generic.

model_qualified_name str

The fully qualified name in case the model endpoint has multiple versions.

Exceptions
Type Description
DBAPIErro

__adrop_model

__adrop_model(model_id: str) -> None

Removes an already registered model.

Parameter
Name Description
model_id str

A unique ID for the model endpoint that you have defined.

__aget_model

__aget_model(
    model_id: str,
) -> typing.Optional[langchain_google_alloydb_pg.model_manager.AlloyDBModel]

Lists the model details for a specific model_id. Returns None if it doesn't exist.

Parameter
Name Description
model_id str

A unique ID for the model endpoint that you have defined.

__alist_models

__alist_models() -> list[langchain_google_alloydb_pg.model_manager.AlloyDBModel]

Lists all the models and its details.

__avalidate

__avalidate() -> None

Private async function to validate prerequisites.

Exceptions
Type Description
Exceptio if google_ml_integration EXTENSION is not 1.5.3.:
Exceptio if google_ml_integration.enable_model_support DB Flag not set.:

__convert_dict_to_dataclass

__convert_dict_to_dataclass(
    list_of_rows: typing.Sequence[sqlalchemy.engine.row.RowMapping],
) -> list[langchain_google_alloydb_pg.model_manager.AlloyDBModel]

Converts a list of DB rows to list of AlloyDBModel dataclass.

Parameter
Name Description
list_of_rows Sequence[RowMapping]

A unique ID for the model endpoint that you define.

__fetch_db_flag

__fetch_db_flag() -> str

Fetches the enable_model_support DB flag.

__fetch_google_ml_extension

__fetch_google_ml_extension() -> str

Creates the Google ML Extension if it does not exist and returns the version number (Default creates version 1.5.3).

__query_db

__query_db(query: str) -> typing.Sequence[sqlalchemy.engine.row.RowMapping]

Queries the Postgres database through the engine.

Parameter
Name Description
query str

Query to execute on the DB.

Exceptions
Type Description
Exceptio if the query is not a returning type.:

acreate_model

acreate_model(
    model_id: str,
    model_provider: str,
    model_type: str,
    model_qualified_name: str,
    **kwargs: dict[str, str]
) -> None

Creates a registration for custom text model.

Parameters
Name Description
model_id str

A unique ID for the model endpoint that you define.

model_provider str

The provider of the model endpoint.

model_type str

The model type. Either text_embedding or generic.

model_qualified_name str

The fully qualified name in case the model endpoint has multiple versions

Exceptions
Type Description
DBAPIErro

adrop_model

adrop_model(model_id: str) -> None

Removes an already registered model.

Parameter
Name Description
model_id str

A unique ID for the model endpoint that you have defined.

aget_model

aget_model(
    model_id: str,
) -> typing.Optional[langchain_google_alloydb_pg.model_manager.AlloyDBModel]

Lists the model details for a specific model_id.

Parameter
Name Description
model_id str

A unique ID for the model endpoint that you have defined.

alist_models

alist_models() -> list[langchain_google_alloydb_pg.model_manager.AlloyDBModel]

Lists all the models and its details.