SparkLLMTextEmbeddings()SparkLLM embedding model integration.
Setup:
To use, you should have the environment variable "SPARK_APP_ID","SPARK_API_KEY" and "SPARK_API_SECRET" set your APP_ID, API_KEY and API_SECRET or pass it as a name parameter to the constructor.
.. code-block:: bash
export SPARK_APP_ID="your-api-id"
export SPARK_API_KEY="your-api-key"
export SPARK_API_SECRET="your-api-secret"
Key init args ā completion params:
api_key: Optional[str]
Automatically inferred from env var SPARK_API_KEY if not provided.
app_id: Optional[str]
Automatically inferred from env var SPARK_APP_ID if not provided.
api_secret: Optional[str]
Automatically inferred from env var SPARK_API_SECRET if not provided.
base_url: Optional[str]
Base URL path for API requests.
See full list of supported init args and their descriptions in the params section.
Instantiate:
.. code-block:: python
from langchain_community.embeddings import SparkLLMTextEmbeddings
embed = SparkLLMTextEmbeddings(
api_key="...",
app_id="...",
api_secret="...",
# other
)
Embed single text:
.. code-block:: python
input_text = "The meaning of life is 42"
embed.embed_query(input_text)
.. code-block:: python
[-0.4912109375, 0.60595703125, 0.658203125, 0.3037109375, 0.6591796875, 0.60302734375, ...]
Embed multiple text:
.. code-block:: python
input_texts = ["This is a test query1.", "This is a test query2."]
embed.embed_documents(input_texts)
.. code-block:: python
[
[-0.1962890625, 0.94677734375, 0.7998046875, -0.1971435546875, 0.445556640625, 0.54638671875, ...],
[ -0.44970703125, 0.06585693359375, 0.7421875, -0.474609375, 0.62353515625, 1.0478515625, ...],
]