Skip to content

Commit

Permalink
cli: embed docstring template (langchain-ai#24855)
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis authored Jul 31, 2024
1 parent 4b2a8ce commit 99eb31e
Showing 1 changed file with 59 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,70 @@


class __ModuleName__Embeddings(Embeddings):
"""__ModuleName__Embeddings embedding model.
"""__ModuleName__ embedding model integration.
Example:
# TODO: Replace with relevant packages, env vars.
Setup:
Install ``__package_name__`` and set environment variable ``__MODULE_NAME___API_KEY``.
.. code-block:: bash
pip install -U __package_name__
export __MODULE_NAME___API_KEY="your-api-key"
# TODO: Populate with relevant params.
Key init args — completion params:
model: str
Name of __ModuleName__ model to use.
See full list of supported init args and their descriptions in the params section.
# TODO: Replace with relevant init params.
Instantiate:
.. code-block:: python
from __module_name__ import __ModuleName__Embeddings
model = __ModuleName__Embeddings()
embed = __ModuleName__Embeddings(
model="...",
# api_key="...",
# other params...
)
Embed single text:
.. code-block:: python
input_text = "The meaning of life is 42"
embed.embed_query(input_text)
.. code-block:: python
# TODO: Example output.
# TODO: Delete if token-level streaming isn't supported.
Embed multiple text:
.. code-block:: python
input_texts = ["Document 1...", "Document 2..."]
embed.embed_documents(input_texts)
.. code-block:: python
# TODO: Example output.
# TODO: Delete if native async isn't supported.
Async:
.. code-block:: python
await embed.aembed_query(input_text)
# multiple:
# await embed.aembed_documents(input_texts)
.. code-block:: python
# TODO: Example output.
"""

def embed_documents(self, texts: List[str]) -> List[List[float]]:
Expand Down

0 comments on commit 99eb31e

Please sign in to comment.