langchain_google_genai.embeddings.GoogleGenerativeAIEmbeddings¶
class langchain_google_genai.embeddings.GoogleGenerativeAIEmbeddings[source]¶
Bases: BaseModel, Embeddings
Google Generative AI Embeddings.
To use, you must have either:
The GOOGLE_API_KEY` environment variable set with your API key, or
Pass your API key using the google_api_key kwarg to the ChatGoogle
constructor.
Example
from langchain_google_genai import GoogleGenerativeAIEmbeddings
embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
embeddings.embed_query("What's our Q1 revenue?")
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param google_api_key: Optional[pydantic.types.SecretStr] = None¶
The Google API key to use. If not provided, the GOOGLE_API_KEY environment variable will be used.
Constraints
type = string
writeOnly = True
format = password
param model: str [Required]¶
The name of the embedding model to use. Example: models/embedding-001
param task_type: Optional[str] = None¶
The task type. Valid options include: task_type_unspecified, retrieval_query, retrieval_document, semantic_similarity, classification, and clustering
async aembed_documents(texts: List[str]) → List[List[float]]¶
Asynchronous Embed search docs.
async aembed_query(text: str) → List[float]¶
Asynchronous Embed query text.
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.