mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
cli: embed docstring template (#24855)
This commit is contained in:
parent
4b2a8ce6c7
commit
99eb31ec41
@ -4,14 +4,70 @@ from langchain_core.embeddings import Embeddings
|
|||||||
|
|
||||||
|
|
||||||
class __ModuleName__Embeddings(Embeddings):
|
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
|
.. code-block:: python
|
||||||
|
|
||||||
from __module_name__ import __ModuleName__Embeddings
|
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]]:
|
def embed_documents(self, texts: List[str]) -> List[List[float]]:
|
||||||
|
Loading…
Reference in New Issue
Block a user