FireworksEmbeddings#

class langchain_fireworks.embeddings.FireworksEmbeddings[source]#

Bases: BaseModel, Embeddings

Fireworks embedding model integration.

Setup:

Install langchain_fireworks and set environment variable FIREWORKS_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 if the input data cannot be parsed to form a valid model.

param fireworks_api_key: SecretStr = SecretStr('')#
Constraints:
  • type = string

  • writeOnly = True

  • format = password

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]

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

Embed search docs.

Parameters:

texts (List[str]) –

Return type:

List[List[float]]

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

Embed query text.

Parameters:

text (str) –

Return type:

List[float]

Examples using FireworksEmbeddings