Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fireworks: Add APIReference for the FireworksEmbeddings model #25292

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 53 additions & 7 deletions libs/partners/fireworks/langchain_fireworks/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,62 @@


class FireworksEmbeddings(BaseModel, Embeddings):
"""FireworksEmbeddings embedding model.
"""Fireworks embedding model integration.

Example:
.. code-block:: python
Setup:
Install ``langchain_fireworks`` and set environment variable
``FIREWORKS_API_KEY``.

from langchain_fireworks import FireworksEmbeddings
.. code-block:: bash

model = FireworksEmbeddings(
model='nomic-ai/nomic-embed-text-v1.5'
)
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:
.. code-block:: python

from __module_name__ 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:
.. code-block:: python

vectors = embeddings.embed_documents(['hello', 'goodbye'])
# Showing only the first 3 coordinates
print(len(vectors))
print(vectors[0][:3])

.. code-block:: python

2
[-0.024603435769677162, -0.007543657906353474, 0.0039630369283258915]


Embed single text:
.. code-block:: python

input_text = "The meaning of life is 42"
vector = embeddings.embed_query('hello')
print(vector[:3])

.. code-block:: python

[-0.024603435769677162, -0.007543657906353474, 0.0039630369283258915]
"""

_client: OpenAI = Field(default=None)
Expand Down
Loading