|
8 | 8 |
|
9 | 9 |
|
10 | 10 | class FireworksEmbeddings(BaseModel, Embeddings):
|
11 |
| - """FireworksEmbeddings embedding model. |
| 11 | + """Fireworks embedding model integration. |
12 | 12 |
|
13 |
| - Example: |
14 |
| - .. code-block:: python |
| 13 | + Setup: |
| 14 | + Install ``langchain_fireworks`` and set environment variable |
| 15 | + ``FIREWORKS_API_KEY``. |
15 | 16 |
|
16 |
| - from langchain_fireworks import FireworksEmbeddings |
| 17 | + .. code-block:: bash |
17 | 18 |
|
18 |
| - model = FireworksEmbeddings( |
19 |
| - model='nomic-ai/nomic-embed-text-v1.5' |
20 |
| - ) |
| 19 | + pip install -U langchain_fireworks |
| 20 | + export FIREWORKS_API_KEY="your-api-key" |
| 21 | +
|
| 22 | + Key init args — completion params: |
| 23 | + model: str |
| 24 | + Name of Fireworks model to use. |
| 25 | +
|
| 26 | + Key init args — client params: |
| 27 | + fireworks_api_key: SecretStr |
| 28 | + Fireworks API key. |
| 29 | +
|
| 30 | + See full list of supported init args and their descriptions in the params section. |
| 31 | +
|
| 32 | + Instantiate: |
| 33 | + .. code-block:: python |
| 34 | +
|
| 35 | + from __module_name__ import FireworksEmbeddings |
| 36 | +
|
| 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 | + ) |
| 42 | +
|
| 43 | + Embed multiple texts: |
| 44 | + .. code-block:: python |
| 45 | +
|
| 46 | + vectors = embeddings.embed_documents(['hello', 'goodbye']) |
| 47 | + # Showing only the first 3 coordinates |
| 48 | + print(len(vectors)) |
| 49 | + print(vectors[0][:3]) |
| 50 | +
|
| 51 | + .. code-block:: python |
| 52 | +
|
| 53 | + 2 |
| 54 | + [-0.024603435769677162, -0.007543657906353474, 0.0039630369283258915] |
| 55 | +
|
| 56 | +
|
| 57 | + Embed single text: |
| 58 | + .. code-block:: python |
| 59 | +
|
| 60 | + input_text = "The meaning of life is 42" |
| 61 | + vector = embeddings.embed_query('hello') |
| 62 | + print(vector[:3]) |
| 63 | +
|
| 64 | + .. code-block:: python |
| 65 | +
|
| 66 | + [-0.024603435769677162, -0.007543657906353474, 0.0039630369283258915] |
21 | 67 | """
|
22 | 68 |
|
23 | 69 | _client: OpenAI = Field(default=None)
|
|
0 commit comments