FireworksEmbeddings#
- class langchain_fireworks.embeddings.FireworksEmbeddings[source]#
Bases:
BaseModel
,Embeddings
Fireworks embedding model integration.
- Setup:
Install
langchain_fireworks
and set environment variableFIREWORKS_API_KEY
.pip install -U langchain_fireworks export FIREWORKS_API_KEY="your-api-key"
- Key init args — completion params:
- model: str
Name of Fireworks model to use.
- Key init args — client params:
- fireworks_api_key: SecretStr
Fireworks API key.
See full list of supported init args and their descriptions in the params section.
- Instantiate:
from langchain_fireworks import FireworksEmbeddings model = FireworksEmbeddings( model='nomic-ai/nomic-embed-text-v1.5' # Use FIREWORKS_API_KEY env var or pass it in directly # fireworks_api_key="..." )
- Embed multiple texts:
vectors = embeddings.embed_documents(['hello', 'goodbye']) # Showing only the first 3 coordinates print(len(vectors)) print(vectors[0][:3])
2 [-0.024603435769677162, -0.007543657906353474, 0.0039630369283258915]
- Embed single text:
input_text = "The meaning of life is 42" vector = embeddings.embed_query('hello') print(vector[:3])
[-0.024603435769677162, -0.007543657906353474, 0.0039630369283258915]
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- param fireworks_api_key: SecretStr [Optional] (alias 'api_key')#
Fireworks API key.
Automatically read from env variable FIREWORKS_API_KEY if not provided.
- param model: str = 'nomic-ai/nomic-embed-text-v1.5'#
- 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]