From 99eb31ec4121e146e007ea584b2d5f4aff2a4337 Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Tue, 30 Jul 2024 19:16:40 -0700 Subject: [PATCH] cli: embed docstring template (#24855) --- .../integration_template/embeddings.py | 62 ++++++++++++++++++- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/libs/cli/langchain_cli/integration_template/integration_template/embeddings.py b/libs/cli/langchain_cli/integration_template/integration_template/embeddings.py index 4827798ef73d1..174c567da8df1 100644 --- a/libs/cli/langchain_cli/integration_template/integration_template/embeddings.py +++ b/libs/cli/langchain_cli/integration_template/integration_template/embeddings.py @@ -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]]: