Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
ccurme committed Dec 4, 2024
1 parent 513cb74 commit 61d1d21
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions docs/docs/contributing/how_to/integrations/vector_stores.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ for all supported methods. The required methods are tabulated below:
| `add_documents` | Add documents to the vector store. |
| `delete` | Delete selected documents from vector store (by IDs) |
| `get_by_ids` | Get selected documents from vector store (by IDs) |
| `similarity_search | Get documents most similar to a query. |
| `similarity_search` | Get documents most similar to a query. |
| `embeddings` (property) | Embeddings object for vector store. |
| `from_texts` | Instantiate vector store via adding texts. |

Expand Down Expand Up @@ -465,7 +465,6 @@ configure what vector store implementation is tested.
First we need to install certain dependencies. These include:

- `pytest`: For running tests
- `pytest-socket`: For running unit tests
- `pytest-asyncio`: For testing async functionality
- `langchain-tests`: For importing standard tests
- `langchain-core`: This should already be installed, but is needed to define our integration.
Expand All @@ -474,16 +473,11 @@ If you followed the previous [bootstrapping guide](/docs/contributing/how_to/int
these should already be installed.

### Add and configure standard tests
There are two namespaces in the langchain-tests package:

- [Unit tests](../../../concepts/testing.mdx#unit-tests) (`langchain_tests.unit_tests`): designed to be used to test the component in isolation and without access to external services
- [Integration tests](../../../concepts/testing.mdx#integration-tests) (`langchain_tests.integration_tests`): designed to be used to test the component with access to external services (in particular, the external service that the component is designed to interact with).

Both types of tests are implemented as [pytest class-based test suites](https://docs.pytest.org/en/7.1.x/getting-started.html#group-multiple-tests-in-a-class).

By subclassing the base classes for each type of standard test (see below), you get
all of the standard tests for that type, and you can override the properties that the
test suite uses to configure the tests.
The `langchain-test` package implements suites of tests for testing vector store
integrations. By subclassing the base classes for each standard test (see below), you
get all of the standard tests for that type, and you can override the properties that
the test suite uses to configure the tests.

Here's how you would configure the standard tests for a typical vector store (using
`ParrotVectorStore` as a placeholder):
Expand All @@ -505,7 +499,7 @@ from langchain_standard_tests.integration_tests.vectorstores import (
class TestSync(ReadWriteTestSuite):
@pytest.fixture()
def vectorstore(self) -> Generator[VectorStore, None, None]: # type: ignore
"""Get an empty vectorstore for unit tests."""
"""Get an empty vectorstore."""
store = ParrotVectorStore()
# note: store should be EMPTY at this point
# if you need to delete data, you may do so here
Expand All @@ -519,7 +513,7 @@ class TestSync(ReadWriteTestSuite):
class TestAsync(AsyncReadWriteTestSuite):
@pytest.fixture()
async def vectorstore(self) -> AsyncGenerator[VectorStore, None]: # type: ignore
"""Get an empty vectorstore for unit tests."""
"""Get an empty vectorstore."""
store = ParrotVectorStore()
# note: store should be EMPTY at this point
# if you need to delete data, you may do so here
Expand Down Expand Up @@ -550,7 +544,7 @@ from langchain_chroma import Chroma
class TestSync(ReadWriteTestSuite):
@pytest.fixture()
def vectorstore(self) -> Generator[VectorStore, None, None]: # type: ignore
"""Get an empty vectorstore for unit tests."""
"""Get an empty vectorstore."""
store = Chroma(embedding_function=self.get_embeddings())
try:
yield store
Expand Down Expand Up @@ -587,4 +581,4 @@ Each test method documents:
This information along with the full set of tests that run can be found in the API
reference. See details:

[Integration tests API reference](https://python.langchain.com/api_reference/standard_tests/integration_tests/langchain_tests.integration_tests.chat_models.ChatModelIntegrationTests.html)
[Test class API reference](https://python.langchain.com/api_reference/standard_tests/integration_tests/langchain_tests.integration_tests.chat_models.ChatModelIntegrationTests.html)

0 comments on commit 61d1d21

Please sign in to comment.