mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-06 13:18:12 +00:00
docs[patch]: update contributor docs for integrations (#28576)
- Reformat tabs - Add code snippets inline - Add embeddings content
This commit is contained in:
parent
f3dc142d3c
commit
15cbc36a23
@ -37,14 +37,11 @@ import CodeBlock from '@theme/CodeBlock';
|
|||||||
Refer to the [Custom Chat Model Guide](/docs/how_to/custom_chat_model) guide for
|
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).
|
detail on a starter chat model [implementation](/docs/how_to/custom_chat_model/#implementation).
|
||||||
|
|
||||||
:::tip
|
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
|
||||||
The model from the [Custom Chat Model Guide](/docs/how_to/custom_chat_model) is tested
|
integration tests in the LangChain Github repository. You can access the starter
|
||||||
against the standard unit and integration tests in the LangChain Github repository.
|
chat model implementation [here](https://github.com/langchain-ai/langchain/blob/master/libs/cli/langchain_cli/integration_template/integration_template/chat_models.py).
|
||||||
You can also access that implementation directly from Github
|
For convenience, we also include the code below.
|
||||||
[here](https://github.com/langchain-ai/langchain/blob/master/libs/standard-tests/tests/unit_tests/custom_chat_model.py).
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Example chat model code</summary>
|
<summary>Example chat model code</summary>
|
||||||
@ -118,9 +115,6 @@ import VectorstoreSource from '../../../../src/theme/integration_template/integr
|
|||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="embeddings" label="Embeddings">
|
<TabItem value="embeddings" label="Embeddings">
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Example embeddings code</summary>
|
|
||||||
|
|
||||||
Embeddings are used to convert `str` objects from `Document.page_content` fields
|
Embeddings are used to convert `str` objects from `Document.page_content` fields
|
||||||
into a vector representation (represented as a list of floats).
|
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.
|
`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';
|
import EmbeddingsSource from '/src/theme/integration_template/integration_template/embeddings.py';
|
||||||
|
|
||||||
|
@ -324,6 +324,28 @@
|
|||||||
" <summary>Embedding Models</summary>"
|
" <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",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@ -347,6 +369,13 @@
|
|||||||
" return {\"model\": \"nest-embed-001\", \"temperature\": 0}"
|
" return {\"model\": \"nest-embed-001\", \"temperature\": 0}"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"Integration test example:"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
Loading…
Reference in New Issue
Block a user