Skip to main content
The LangDBEmbedder class is used to embed text data into vectors using the LangDB API. This embedder provides high-quality embeddings that can be used with various vector databases for semantic search and similarity matching.

Usage

langdb_embedder.py
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.embedder.langdb import LangDBEmbedder
from agno.vectordb.pgvector import PgVector

# Get embeddings for a text
embeddings = LangDBEmbedder().get_embedding("Embed me")

# Print the embeddings and their dimensions
print(f"Embeddings: {embeddings[:5]}")
print(f"Dimensions: {len(embeddings)}")

# Example usage with a knowledge base:
knowledge = Knowledge(
    vector_db=PgVector(
        db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
        table_name="langdb_embeddings",
        embedder=LangDBEmbedder(),
    ),
    max_results=2,
)

Params

ParameterTypeDefaultDescription
api_keystr-The API key used for authenticating requests to LangDB
project_idstr-The project ID associated with your LangDB account
modelstr-The name of the model used for generating embeddings
dimensionsint-The dimensionality of the embeddings generated by the model
base_urlstr-The base URL for the LangDB API endpoint
request_paramsOptional[Dict[str, Any]]-Additional parameters to include in the API request
client_paramsOptional[Dict[str, Any]]-Additional parameters for configuring the API client

Environment Variables

export LANGDB_API_KEY=xxx
export LANGDB_PROJECT_ID=xxx

Developer Resources