From 15cbc36a2379244db331e77ab3eadb5d7967943b Mon Sep 17 00:00:00 2001 From: ccurme Date: Fri, 6 Dec 2024 13:33:24 -0500 Subject: [PATCH] docs[patch]: update contributor docs for integrations (#28576) - Reformat tabs - Add code snippets inline - Add embeddings content --- .../how_to/integrations/package.mdx | 25 ++++++++-------- .../how_to/integrations/standard_tests.ipynb | 29 +++++++++++++++++++ 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/docs/docs/contributing/how_to/integrations/package.mdx b/docs/docs/contributing/how_to/integrations/package.mdx index d016ff1bed4..5a4aa697c25 100644 --- a/docs/docs/contributing/how_to/integrations/package.mdx +++ b/docs/docs/contributing/how_to/integrations/package.mdx @@ -37,14 +37,11 @@ import CodeBlock from '@theme/CodeBlock'; Refer to the [Custom Chat Model Guide](/docs/how_to/custom_chat_model) guide for detail on a starter chat model [implementation](/docs/how_to/custom_chat_model/#implementation). - :::tip - - The model from the [Custom Chat Model Guide](/docs/how_to/custom_chat_model) is tested - against the standard unit and integration tests in the LangChain Github repository. - You can also access that implementation directly from Github - [here](https://github.com/langchain-ai/langchain/blob/master/libs/standard-tests/tests/unit_tests/custom_chat_model.py). - - ::: + The `langchain-cli` package contains [template integrations](https://github.com/langchain-ai/langchain/tree/master/libs/cli/langchain_cli/integration_template/integration_template) + for major LangChain components that are tested against the standard unit and + integration tests in the LangChain Github repository. You can access the starter + chat model implementation [here](https://github.com/langchain-ai/langchain/blob/master/libs/cli/langchain_cli/integration_template/integration_template/chat_models.py). + For convenience, we also include the code below.
Example chat model code @@ -118,9 +115,6 @@ import VectorstoreSource from '../../../../src/theme/integration_template/integr -
- Example embeddings code - Embeddings are used to convert `str` objects from `Document.page_content` fields into a vector representation (represented as a list of floats). @@ -154,9 +148,16 @@ implement this method to handle that. `embed_documents` takes in a list of strings and returns a list of embeddings as a list of lists of floats. +### Implementation -### Async methods +The `langchain-cli` package contains [template integrations](https://github.com/langchain-ai/langchain/tree/master/libs/cli/langchain_cli/integration_template/integration_template) +for major LangChain components that are tested against the standard unit and +integration tests in the LangChain Github repository. You can access the starter +embedding model implementation [here](https://github.com/langchain-ai/langchain/blob/master/libs/cli/langchain_cli/integration_template/integration_template/embeddings.py). +For convenience, we also include the code below. +
+ Example embeddings code import EmbeddingsSource from '/src/theme/integration_template/integration_template/embeddings.py'; diff --git a/docs/docs/contributing/how_to/integrations/standard_tests.ipynb b/docs/docs/contributing/how_to/integrations/standard_tests.ipynb index a01dc8a60a3..dbf1a1a9b1c 100644 --- a/docs/docs/contributing/how_to/integrations/standard_tests.ipynb +++ b/docs/docs/contributing/how_to/integrations/standard_tests.ipynb @@ -324,6 +324,28 @@ " Embedding Models" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To configure standard tests for an embeddings model, we subclass\n", + "`EmbeddingsUnitTests` and `EmbeddingsIntegrationTests`. On each subclass, we\n", + "implement the `embeddings_class` property to specify the embeddings model to be\n", + "tested. We can also override the embedding_model_params property to specify\n", + "initialization parameters. See examples below.\n", + "\n", + ":::note\n", + "\n", + "Details on what tests are run, how each test can be skipped, and troubleshooting tips for each test can be found in the API references. See details:\n", + "\n", + "- [Unit tests API reference](https://python.langchain.com/api_reference/standard_tests/unit_tests/langchain_tests.unit_tests.embeddings.EmbeddingsUnitTests.html)\n", + "- [Integration tests API reference](https://python.langchain.com/api_reference/standard_tests/integration_tests/langchain_tests.integration_tests.embeddings.EmbeddingsIntegrationTests.html)\n", + "\n", + ":::\n", + "\n", + "Unit test example:" + ] + }, { "cell_type": "code", "execution_count": null, @@ -347,6 +369,13 @@ " return {\"model\": \"nest-embed-001\", \"temperature\": 0}" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Integration test example:" + ] + }, { "cell_type": "code", "execution_count": null,