genai.extensions.langchain.embeddings module#

pydantic model genai.extensions.langchain.embeddings.LangChainEmbeddingsInterface[source]#

Bases: BaseModel, Embeddings

Class representing the LangChainChatInterface for interacting with the LangChain chat API.

Example:

from genai import Client, Credentials
from genai.extensions.langchain import LangChainEmbeddingsInterface
from genai.text.embedding import TextEmbeddingParameters

client = Client(credentials=Credentials.from_env())
embeddings = LangChainEmbeddingsInterface(
    client=client,
    model_id="sentence-transformers/all-minilm-l6-v2",
    parameters=TextEmbeddingParameters(truncate_input_tokens=True)
)

embeddings.embed_query("Hello world!")
embeddings.embed_documents(["First document", "Second document"])
Config:
  • extra: str = forbid

  • protected_namespaces: tuple = ()

  • arbitrary_types_allowed: bool = True

field client: Client [Required]#
field execution_options: ModelLike[CreateExecutionOptions] | None = None#
field model_id: str [Required]#
field parameters: ModelLike[TextEmbeddingParameters] | None = None#
async aembed_documents(texts)[source]#

Asynchronous Embed search documents

Parameters:

texts (List[str]) –

Return type:

list[list[float]]

async aembed_query(text)[source]#

Asynchronous Embed query text.

Parameters:

text (str) –

Return type:

List[float]

embed_documents(texts)[source]#

Embed search documents

Parameters:

texts (list[str]) –

Return type:

list[list[float]]

embed_query(text)[source]#

Embed query text.

Parameters:

text (str) –

Return type:

list[float]