Skip to content

Commit

Permalink
docs[patch]: update contributor docs for integrations (#28576)
Browse files Browse the repository at this point in the history
- Reformat tabs
- Add code snippets inline
- Add embeddings content
  • Loading branch information
ccurme authored Dec 6, 2024
1 parent f3dc142 commit 15cbc36
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
25 changes: 13 additions & 12 deletions docs/docs/contributing/how_to/integrations/package.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details>
<summary>Example chat model code</summary>
Expand Down Expand Up @@ -118,9 +115,6 @@ import VectorstoreSource from '../../../../src/theme/integration_template/integr
</TabItem>
<TabItem value="embeddings" label="Embeddings">

<details>
<summary>Example embeddings code</summary>

Embeddings are used to convert `str` objects from `Document.page_content` fields
into a vector representation (represented as a list of floats).

Expand Down Expand Up @@ -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.

<details>
<summary>Example embeddings code</summary>

import EmbeddingsSource from '/src/theme/integration_template/integration_template/embeddings.py';

Expand Down
29 changes: 29 additions & 0 deletions docs/docs/contributing/how_to/integrations/standard_tests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,28 @@
" <summary>Embedding Models</summary>"
]
},
{
"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,
Expand All @@ -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,
Expand Down

0 comments on commit 15cbc36

Please sign in to comment.