DatabricksEmbeddings#

class langchain_databricks.embeddings.DatabricksEmbeddings[source]#

Bases: Embeddings, BaseModel

Databricks embedding model integration.

Setup:

Install langchain-databricks.

pip install -U langchain-databricks

If you are outside Databricks, set the Databricks workspace hostname and personal access token to environment variables:

export DATABRICKS_HOSTNAME="https://your-databricks-workspace"
export DATABRICKS_TOKEN="your-personal-access-token"
Key init args — completion params:
endpoint: str

Name of Databricks Model Serving endpoint to query.

target_uri: str

The target URI to use. Defaults to databricks.

query_params: Dict[str, str]

The parameters to use for queries.

documents_params: Dict[str, str]

The parameters to use for documents.

Instantiate:
Embed single text:
param documents_params: Dict[str, Any] = {}#

The target URI to use.

param endpoint: str [Required]#

The endpoint to use.

param query_params: Dict[str, Any] = {}#

The parameters to use for documents.

param target_uri: str = 'databricks'#

The parameters to use for queries.

async aembed_documents(texts: list[str]) list[list[float]]#

Asynchronous Embed search docs.

Parameters:

texts (list[str]) – List of text to embed.

Returns:

List of embeddings.

Return type:

list[list[float]]

async aembed_query(text: str) list[float]#

Asynchronous Embed query text.

Parameters:

text (str) – Text to embed.

Returns:

Embedding.

Return type:

list[float]

embed_documents(texts: List[str]) List[List[float]][source]#

Embed search docs.

Parameters:

texts (List[str]) – List of text to embed.

Returns:

List of embeddings.

Return type:

List[List[float]]

embed_query(text: str) List[float][source]#

Embed query text.

Parameters:

text (str) – Text to embed.

Returns:

Embedding.

Return type:

List[float]

Examples using DatabricksEmbeddings