diff --git a/docs/docs/contributing/how_to/index.mdx b/docs/docs/contributing/how_to/index.mdx index e4eda7ddbc1d8..d9f903f4156d6 100644 --- a/docs/docs/contributing/how_to/index.mdx +++ b/docs/docs/contributing/how_to/index.mdx @@ -2,4 +2,8 @@ - [**Documentation**](documentation/index.mdx): Help improve our docs, including this one! - [**Code**](code/index.mdx): Help us write code, fix bugs, or improve our infrastructure. -- [**Integrations**](integrations/index.mdx): Help us integrate with your favorite vendors and tools. \ No newline at end of file + +## Integrations + +- [**Start Here**](integrations/index.mdx): Help us integrate with your favorite vendors and tools. +- [**Standard Tests**](integrations/standard_tests): Ensure your integration passes an expected set of tests. diff --git a/docs/docs/contributing/how_to/integrations/community.mdx b/docs/docs/contributing/how_to/integrations/community.mdx index a33ae002cd0d4..c7c3dadef917e 100644 --- a/docs/docs/contributing/how_to/integrations/community.mdx +++ b/docs/docs/contributing/how_to/integrations/community.mdx @@ -1,13 +1,11 @@ -## How to add a community integration (deprecated guide) +## How to add a community integration (not recommended) :::danger -We are no longer accepting new community integrations. Please see the -[main integration guide](./index.mdx) for more information on contributing new -integrations. +We recommend following the [main integration guide](./index.mdx) to add new integrations instead. -Note that `langchain-community` is **not** deprecated. Only -the process for adding new community integrations is deprecated. +If you follow this guide, there is a high likelihood we will close your PR with the above +guide linked without much discussion. ::: diff --git a/docs/docs/contributing/how_to/integrations/index.mdx b/docs/docs/contributing/how_to/integrations/index.mdx index 5f08dce43606e..159f4ac4e999b 100644 --- a/docs/docs/contributing/how_to/integrations/index.mdx +++ b/docs/docs/contributing/how_to/integrations/index.mdx @@ -65,10 +65,10 @@ that will render on this site (https://python.langchain.com/). As a prerequisite to adding your integration to our documentation, you must: -1. Confirm that your integration is in the list of components we are currently accepting. +1. Confirm that your integration is in the [list of components](#components-to-integrate) we are currently accepting. 2. Ensure that your integration is in a separate package that can be installed with `pip install `. -3. Implement the standard tests for your integration and successfully run them. -3. Write documentation for your integration in the `docs/docs/integrations` directory of the LangChain monorepo. +3. [Implement the standard tests](/docs/contributing/how_to/integrations/standard_tests) for your integration and successfully run them. +3. Write documentation for your integration in the `docs/docs/integrations/` directory of the LangChain monorepo. 4. Add a provider page for your integration in the `docs/docs/integrations/providers` directory of the LangChain monorepo. Once you have completed these steps, you can submit a PR to the LangChain monorepo to add your integration to the documentation. diff --git a/docs/docs/contributing/how_to/integrations/standard_tests.ipynb b/docs/docs/contributing/how_to/integrations/standard_tests.ipynb index c741a76077304..40aa9c3b2a19c 100644 --- a/docs/docs/contributing/how_to/integrations/standard_tests.ipynb +++ b/docs/docs/contributing/how_to/integrations/standard_tests.ipynb @@ -6,16 +6,14 @@ "source": [ "# How to add standard tests to an integration\n", "\n", - "Implementing standard tests \n", - "\n", - "When creating either a custom class for yourself or a new tool to publish in a LangChain integration, it is important to add standard tests to ensure it works as expected. This guide will show you how to add standard tests to a tool, and the templates for implementing each different kind of integration are linked [at the bottom](#standard-test-templates-per-component).\n", + "When creating either a custom class for yourself or a new tool to publish in a LangChain integration, it is important to add standard tests to ensure it works as expected. This guide will show you how to add standard tests to a tool, and you can **[Skip to the test templates](#standard-test-templates-per-component)** for implementing tests for each integration.\n", "\n", "## Setup\n", "\n", "First, let's install 2 dependencies:\n", "\n", "- `langchain-core` will define the interfaces we want to import to define our custom tool.\n", - "- `langchain-tests==0.3.0` will provide the standard tests we want to use.\n", + "- `langchain-tests==0.3.2` will provide the standard tests we want to use.\n", "\n", ":::note\n", "\n", @@ -26,7 +24,7 @@ "or in a new release of `langchain-tests`.\n", "\n", "Because added tests in new versions of `langchain-tests` will always break your CI/CD pipelines, we recommend pinning the \n", - "version of `langchain-tests==0.3.0` to avoid unexpected changes.\n", + "version of `langchain-tests==0.3.2` to avoid unexpected changes.\n", "\n", ":::" ] @@ -37,7 +35,7 @@ "metadata": {}, "outputs": [], "source": [ - "%pip install -U langchain-core langchain-tests==0.3.0 pytest pytest-socket" + "%pip install -U langchain-core langchain-tests==0.3.2 pytest pytest-socket" ] }, { @@ -223,7 +221,11 @@ "class TestChatParrotLinkUnit(ChatModelUnitTests):\n", " @property\n", " def chat_model_class(self) -> Type[ChatParrotLink]:\n", - " return ChatParrotLink" + " return ChatParrotLink\n", + "\n", + " @property\n", + " def chat_model_params(self) -> dict:\n", + " return {\"model\": \"bird-brain-001\", \"temperature\": 0}" ] }, { @@ -254,22 +256,54 @@ "metadata": {}, "source": [ "\n", - "\n", - "
\n", - "Work in progress:\n", "
\n", - " Retrievers\n", - " TODO" + " Embedding Models" ] }, { - "cell_type": "markdown", + "cell_type": "code", + "execution_count": null, "metadata": {}, + "outputs": [], "source": [ - "
\n", - "
\n", - " Vector Stores\n", - " TODO" + "# title=\"tests/unit_tests/test_embeddings.py\"\n", + "from typing import Tuple, Type\n", + "\n", + "from langchain_parrot_link.embeddings import ParrotLinkEmbeddings\n", + "from langchain_standard_tests.unit_tests import EmbeddingsUnitTests\n", + "\n", + "\n", + "class TestParrotLinkEmbeddingsUnit(EmbeddingsUnitTests):\n", + " @property\n", + " def embeddings_class(self) -> Type[ParrotLinkEmbeddings]:\n", + " return ParrotLinkEmbeddings\n", + "\n", + " @property\n", + " def embedding_model_params(self) -> dict:\n", + " return {\"model\": \"nest-embed-001\", \"temperature\": 0}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# title=\"tests/integration_tests/test_embeddings.py\"\n", + "from typing import Type\n", + "\n", + "from langchain_parrot_link.embeddings import ParrotLinkEmbeddings\n", + "from langchain_standard_tests.integration_tests import EmbeddingsIntegrationTests\n", + "\n", + "\n", + "class TestParrotLinkEmbeddingsIntegration(EmbeddingsIntegrationTests):\n", + " @property\n", + " def embeddings_class(self) -> Type[ParrotLinkEmbeddings]:\n", + " return ParrotLinkEmbeddings\n", + "\n", + " @property\n", + " def embedding_model_params(self) -> dict:\n", + " return {\"model\": \"nest-embed-001\", \"temperature\": 0}" ] }, { @@ -278,16 +312,83 @@ "source": [ "
\n", "
\n", - " Embedding Models\n", - " TODO" + " Tools/Toolkits\n", + " Note: The standard tests for tools/toolkits are implemented in the example in the main body of this guide too." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# title=\"tests/unit_tests/test_tools.py\"\n", + "from typing import Type\n", + "\n", + "from langchain_parrot_link.tools import ParrotMultiplyTool\n", + "from langchain_standard_tests.unit_tests import ToolsUnitTests\n", + "\n", + "\n", + "class TestParrotMultiplyToolUnit(ToolsUnitTests):\n", + " @property\n", + " def tool_constructor(self) -> Type[ParrotMultiplyTool]:\n", + " return ParrotMultiplyTool\n", + "\n", + " def tool_constructor_params(self) -> dict:\n", + " # if your tool constructor instead required initialization arguments like\n", + " # `def __init__(self, some_arg: int):`, you would return those here\n", + " # as a dictionary, e.g.: `return {'some_arg': 42}`\n", + " return {}\n", + "\n", + " def tool_invoke_params_example(self) -> dict:\n", + " \"\"\"\n", + " Returns a dictionary representing the \"args\" of an example tool call.\n", + "\n", + " This should NOT be a ToolCall dict - i.e. it should not\n", + " have {\"name\", \"id\", \"args\"} keys.\n", + " \"\"\"\n", + " return {\"a\": 2, \"b\": 3}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# title=\"tests/integration_tests/test_tools.py\"\n", + "from typing import Type\n", + "\n", + "from langchain_parrot_link.tools import ParrotMultiplyTool\n", + "from langchain_standard_tests.integration_tests import ToolsIntegrationTests\n", + "\n", + "\n", + "class TestParrotMultiplyToolIntegration(ToolsIntegrationTests):\n", + " @property\n", + " def tool_constructor(self) -> Type[ParrotMultiplyTool]:\n", + " return ParrotMultiplyTool\n", + "\n", + " def tool_constructor_params(self) -> dict:\n", + " # if your tool constructor instead required initialization arguments like\n", + " # `def __init__(self, some_arg: int):`, you would return those here\n", + " # as a dictionary, e.g.: `return {'some_arg': 42}`\n", + " return {}\n", + "\n", + " def tool_invoke_params_example(self) -> dict:\n", + " \"\"\"\n", + " Returns a dictionary representing the \"args\" of an example tool call.\n", + "\n", + " This should NOT be a ToolCall dict - i.e. it should not\n", + " have {\"name\", \"id\", \"args\"} keys.\n", + " \"\"\"\n", + " return {\"a\": 2, \"b\": 3}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "
\n", - "
" + "" ] } ], diff --git a/docs/docs/contributing/index.mdx b/docs/docs/contributing/index.mdx index 67930710585dc..d2c1231789d8d 100644 --- a/docs/docs/contributing/index.mdx +++ b/docs/docs/contributing/index.mdx @@ -17,6 +17,7 @@ More coming soon! We are working on tutorials to help you make your first contri - [**Documentation**](how_to/documentation/index.mdx): Help improve our docs, including this one! - [**Code**](how_to/code/index.mdx): Help us write code, fix bugs, or improve our infrastructure. - [**Integrations**](how_to/integrations/index.mdx): Help us integrate with your favorite vendors and tools. +- [**Standard Tests**](how_to/integrations/standard_tests): Ensure your integration passes an expected set of tests. ## Reference