AlloyDBEmbeddings(
key: object, engine: langchain_google_alloydb_pg.engine.AlloyDBEngine, model_id: str
)Google AlloyDB Embeddings available via Model Endpoint Management.
Methods
AlloyDBEmbeddings
AlloyDBEmbeddings(
key: object, engine: langchain_google_alloydb_pg.engine.AlloyDBEngine, model_id: str
)AlloyDBEmbeddings constructor.
| Parameters | |
|---|---|
| Name | Description |
key |
object
Prevent direct constructor usage. |
engine |
AlloyDBEngine
Connection pool engine for managing connections to Postgres database. |
model_id |
str
The model id used for generating embeddings. |
| Exceptions | |
|---|---|
| Type | Description |
ValueError |
if model does not exist. Use AlloyDBModelManager to create the model. |
__aembed_image
__aembed_image(image_uri: str) -> list[float]Coroutine for generating embeddings for a given image.
| Parameter | |
|---|---|
| Name | Description |
image_uri |
str
Cloud Storage URI ( |
| Returns | |
|---|---|
| Type | Description |
list[float] |
Embedding vector. |
__aembed_query
__aembed_query(query: str) -> list[float]Coroutine for generating embeddings for a given query.
| Parameter | |
|---|---|
| Name | Description |
query |
str
Text to embed. |
| Returns | |
|---|---|
| Type | Description |
list[float] |
Embedding. |
__amodel_exists
__amodel_exists() -> boolChecks if the embedding model exists.
| Returns | |
|---|---|
| Type | Description |
|
True if a model with the given name exists, False otherwise. |
aembed_documents
aembed_documents(texts: list[str]) -> list[list[float]]Asynchronous Embed search docs.
aembed_image
aembed_image(image_uri: str) -> list[float]Asynchronous Embed image using google_ml.image_embedding.
Requires the google_ml_integration extension with the
google_ml_integration.enable_model_support database flag set to
on and a registered multimodal embedding model such as
multimodalembedding@001.
| Parameter | |
|---|---|
| Name | Description |
image_uri |
str
Cloud Storage URI ( |
| Exceptions | |
|---|---|
| Type | Description |
ValueError |
If image_uri is empty or whitespace. |
sqlalchemy.exc.DBAPIError |
If the database query fails. |
| Returns | |
|---|---|
| Type | Description |
list[float] |
Embedding vector. |
aembed_query
aembed_query(text: str) -> list[float]Asynchronous Embed query text.
| Parameter | |
|---|---|
| Name | Description |
query |
str
Text to embed. |
| Returns | |
|---|---|
| Type | Description |
list[float] |
Embedding. |
amodel_exists
amodel_exists() -> boolChecks if the embedding model exists.
| Returns | |
|---|---|
| Type | Description |
|
True if a model with the given name exists, False otherwise. |
create
create(
engine: langchain_google_alloydb_pg.engine.AlloyDBEngine, model_id: str
) -> langchain_google_alloydb_pg.embeddings.AlloyDBEmbeddingsCreate AlloyDBEmbeddings instance.
| Parameters | |
|---|---|
| Name | Description |
key |
object
Prevent direct constructor usage. |
engine |
AlloyDBEngine
Connection pool engine for managing connections to Postgres database. |
model_id |
str
The model id used for generating embeddings. |
| Returns | |
|---|---|
| Type | Description |
AlloyDBEmbeddings |
Instance of AlloyDBEmbeddings. |
create_sync
create_sync(
engine: langchain_google_alloydb_pg.engine.AlloyDBEngine, model_id: str
) -> langchain_google_alloydb_pg.embeddings.AlloyDBEmbeddingsCreate AlloyDBEmbeddings instance.
| Parameters | |
|---|---|
| Name | Description |
key |
object
Prevent direct constructor usage. |
engine |
AlloyDBEngine
Connection pool engine for managing connections to Postgres database. |
model_id |
str
The model id used for generating embeddings. |
| Returns | |
|---|---|
| Type | Description |
AlloyDBEmbeddings |
Instance of AlloyDBEmbeddings. |
embed_documents
embed_documents(texts: list[str]) -> list[list[float]]Embed search docs.
embed_image
embed_image(image_uri: str) -> list[float]Embed image using google_ml.image_embedding.
Requires the google_ml_integration extension with the
google_ml_integration.enable_model_support database flag set to
on and a registered multimodal embedding model such as
multimodalembedding@001.
| Parameter | |
|---|---|
| Name | Description |
image_uri |
str
Cloud Storage URI ( |
| Exceptions | |
|---|---|
| Type | Description |
ValueError |
If image_uri is empty or whitespace. |
sqlalchemy.exc.DBAPIError |
If the database query fails. |
| Returns | |
|---|---|
| Type | Description |
list[float] |
Embedding vector. |
embed_query
embed_query(text: str) -> list[float]Embed query text.
| Parameter | |
|---|---|
| Name | Description |
query |
str
Text to embed. |
| Returns | |
|---|---|
| Type | Description |
list[float] |
Embedding. |
model_exists
model_exists() -> boolChecks if the embedding model exists.
| Returns | |
|---|---|
| Type | Description |
|
True if a model with the given name exists, False otherwise. |