Skip to content

Commit 999f7d0

Browse files
committed
x
1 parent 3ffb6b9 commit 999f7d0

File tree

1 file changed

+36
-39
lines changed

1 file changed

+36
-39
lines changed

libs/partners/fireworks/langchain_fireworks/embeddings.py

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,65 @@
44
from langchain_core.embeddings import Embeddings
55
from langchain_core.pydantic_v1 import BaseModel, Field, SecretStr, root_validator
66
from langchain_core.utils import convert_to_secret_str
7-
87
from openai import OpenAI # type: ignore
98

109

1110
class FireworksEmbeddings(BaseModel, Embeddings):
1211
"""Fireworks embedding model integration.
1312
14-
Setup:
15-
Install ``langchain_fireworks`` and set environment variable ``FIREWORKS_API_KEY``.
16-
17-
.. code-block:: bash
18-
19-
pip install -U langchain_fireworks
20-
export FIREWORKS_API_KEY="your-api-key"
13+
Setup:
14+
Install ``langchain_fireworks`` and set environment variable ``FIREWORKS_API_KEY``.
2115
22-
Key init args — completion params:
23-
model: str
24-
Name of Fireworks model to use.
16+
.. code-block:: bash
2517
26-
Key init args — client params:
27-
fireworks_api_key: SecretStr
28-
Fireworks API key.
18+
pip install -U langchain_fireworks
19+
export FIREWORKS_API_KEY="your-api-key"
2920
30-
See full list of supported init args and their descriptions in the params section.
21+
Key init args — completion params:
22+
model: str
23+
Name of Fireworks model to use.
3124
32-
Instantiate:
33-
.. code-block:: python
25+
Key init args — client params:
26+
fireworks_api_key: SecretStr
27+
Fireworks API key.
3428
35-
from __module_name__ import FireworksEmbeddings
29+
See full list of supported init args and their descriptions in the params section.
3630
37-
model = FireworksEmbeddings(
38-
model='nomic-ai/nomic-embed-text-v1.5'
39-
# Use FIREWORKS_API_KEY env var or pass it in directly
40-
# fireworks_api_key="..."
41-
)
31+
Instantiate:
32+
.. code-block:: python
4233
43-
Embed multiple texts:
34+
from __module_name__ import FireworksEmbeddings
4435
45-
.. code-block:: python
36+
model = FireworksEmbeddings(
37+
model='nomic-ai/nomic-embed-text-v1.5'
38+
# Use FIREWORKS_API_KEY env var or pass it in directly
39+
# fireworks_api_key="..."
40+
)
4641
47-
vectors = embeddings.embed_documents(['hello', 'goodbye'])
48-
# Showing only the first 3 coordinates
49-
print(len(vectors))
50-
print(vectors[0][:3])
42+
Embed multiple texts:
43+
.. code-block:: python
5144
52-
.. code-block:: python
45+
vectors = embeddings.embed_documents(['hello', 'goodbye'])
46+
# Showing only the first 3 coordinates
47+
print(len(vectors))
48+
print(vectors[0][:3])
5349
54-
2
55-
[-0.024603435769677162, -0.007543657906353474, 0.0039630369283258915]
50+
.. code-block:: python
5651
52+
2
53+
[-0.024603435769677162, -0.007543657906353474, 0.0039630369283258915]
5754
58-
Embed single text:
5955
60-
.. code-block:: python
56+
Embed single text:
57+
.. code-block:: python
6158
62-
input_text = "The meaning of life is 42"
63-
vector = embeddings.embed_query('hello')
64-
print(vector[:3])
59+
input_text = "The meaning of life is 42"
60+
vector = embeddings.embed_query('hello')
61+
print(vector[:3])
6562
66-
.. code-block:: python
63+
.. code-block:: python
6764
68-
[-0.024603435769677162, -0.007543657906353474, 0.0039630369283258915]
65+
[-0.024603435769677162, -0.007543657906353474, 0.0039630369283258915]
6966
"""
7067

7168
_client: OpenAI = Field(default=None)

0 commit comments

Comments
 (0)