mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
style: refs pass (#33813)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Standard tests for the BaseStore abstraction.
|
||||
"""Standard tests for the `BaseStore` abstraction.
|
||||
|
||||
We don't recommend implementing externally managed BaseStore abstractions at this time.
|
||||
We don't recommend implementing externally managed `BaseStore` abstractions at this
|
||||
time.
|
||||
"""
|
||||
|
||||
from abc import abstractmethod
|
||||
@@ -16,9 +17,9 @@ V = TypeVar("V")
|
||||
|
||||
|
||||
class BaseStoreSyncTests(BaseStandardTests, Generic[V]):
|
||||
"""Test suite for checking the key-value API of a BaseStore.
|
||||
"""Test suite for checking the key-value API of a `BaseStore`.
|
||||
|
||||
This test suite verifies the basic key-value API of a BaseStore.
|
||||
This test suite verifies the basic key-value API of a `BaseStore`.
|
||||
|
||||
The test suite is designed for synchronous key-value stores.
|
||||
|
||||
@@ -162,9 +163,9 @@ class BaseStoreSyncTests(BaseStandardTests, Generic[V]):
|
||||
|
||||
|
||||
class BaseStoreAsyncTests(BaseStandardTests, Generic[V]):
|
||||
"""Test suite for checking the key-value API of a BaseStore.
|
||||
"""Test suite for checking the key-value API of a `BaseStore`.
|
||||
|
||||
This test suite verifies the basic key-value API of a BaseStore.
|
||||
This test suite verifies the basic key-value API of a `BaseStore`.
|
||||
|
||||
The test suite is designed for synchronous key-value stores.
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Standard tests for the BaseCache abstraction.
|
||||
"""Standard tests for the `BaseCache` abstraction.
|
||||
|
||||
We don't recommend implementing externally managed BaseCache abstractions at this time.
|
||||
We don't recommend implementing externally managed `BaseCache` abstractions at this
|
||||
time.
|
||||
"""
|
||||
|
||||
from abc import abstractmethod
|
||||
@@ -13,7 +14,7 @@ from langchain_tests.base import BaseStandardTests
|
||||
|
||||
|
||||
class SyncCacheTestSuite(BaseStandardTests):
|
||||
"""Test suite for checking the BaseCache API of a caching layer for LLMs.
|
||||
"""Test suite for checking the `BaseCache` API of a caching layer for LLMs.
|
||||
|
||||
This test suite verifies the basic caching API of a caching layer for LLMs.
|
||||
|
||||
@@ -106,9 +107,9 @@ class SyncCacheTestSuite(BaseStandardTests):
|
||||
|
||||
|
||||
class AsyncCacheTestSuite(BaseStandardTests):
|
||||
"""Test suite for checking the BaseCache API of a caching layer for LLMs.
|
||||
"""Test suite for checking the `BaseCache` API of a caching layer for LLMs.
|
||||
|
||||
This test suite verifies the basic caching API of a caching layer for LLMs.
|
||||
Verifies the basic caching API of a caching layer for LLMs.
|
||||
|
||||
The test suite is designed for synchronous caching layers.
|
||||
|
||||
|
||||
@@ -292,7 +292,9 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
??? info "`structured_output_kwargs`"
|
||||
|
||||
Dict property that can be used to specify additional kwargs for
|
||||
`with_structured_output`. Useful for testing different models.
|
||||
`with_structured_output`.
|
||||
|
||||
Useful for testing different models.
|
||||
|
||||
```python
|
||||
@property
|
||||
@@ -436,7 +438,9 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
Boolean property indicating whether the chat model supports image inputs.
|
||||
|
||||
Defaults to `False`. No current tests are written for this feature.
|
||||
Defaults to `False`.
|
||||
|
||||
No current tests are written for this feature.
|
||||
|
||||
??? info "`returns_usage_metadata`"
|
||||
|
||||
@@ -504,7 +508,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
)
|
||||
```
|
||||
|
||||
as well as the LangChain `ImageContentBlock` format:
|
||||
...as well as the LangChain `ImageContentBlock` format:
|
||||
|
||||
```python
|
||||
ToolMessage(
|
||||
@@ -688,7 +692,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
gunzip -k /path/to/tests/cassettes/TestClass_test.yaml.gz
|
||||
```
|
||||
|
||||
or by using the serializer:
|
||||
...or by using the serializer:
|
||||
|
||||
```python
|
||||
from langchain_tests.conftest import (
|
||||
@@ -766,7 +770,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
because `ainvoke` has a default implementation that calls `invoke` in an
|
||||
async context.
|
||||
|
||||
If that test passes but not this one, you should make sure your _agenerate
|
||||
If that test passes but not this one, you should make sure your `_agenerate`
|
||||
method does not raise any exceptions, and that it returns a valid
|
||||
`langchain_core.outputs.chat_result.ChatResult` like so:
|
||||
|
||||
@@ -876,7 +880,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
If that test passes but not this one, you should make sure your `batch`
|
||||
method does not raise any exceptions, and that it returns a list of valid
|
||||
`langchain_core.messages.AIMessage` objects.
|
||||
`AIMessage` objects.
|
||||
|
||||
"""
|
||||
batch_results = model.batch(["Hello", "Hey"])
|
||||
@@ -906,7 +910,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
If those tests pass but not this one, you should make sure your `abatch`
|
||||
method does not raise any exceptions, and that it returns a list of valid
|
||||
`langchain_core.messages.AIMessage` objects.
|
||||
`AIMessage` objects.
|
||||
|
||||
"""
|
||||
batch_results = await model.abatch(["Hello", "Hey"])
|
||||
@@ -923,8 +927,8 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
"""Test to verify that the model can handle multi-turn conversations.
|
||||
|
||||
This should pass for all integrations. Tests the model's ability to process
|
||||
a sequence of alternating human and AI messages as context for generating
|
||||
the next response.
|
||||
a sequence of alternating `HumanMessage` and `AIMessage` objects as context for
|
||||
generating the next response.
|
||||
|
||||
??? question "Troubleshooting"
|
||||
|
||||
@@ -933,6 +937,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
because this test also uses `model.invoke`.
|
||||
|
||||
If that test passes but not this one, you should verify that:
|
||||
|
||||
1. Your model correctly processes the message history
|
||||
2. The model maintains appropriate context from previous messages
|
||||
3. The response is a valid `langchain_core.messages.AIMessage`
|
||||
@@ -968,8 +973,9 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
because this test is the "basic case" without double messages.
|
||||
|
||||
If that test passes those but not this one, you should verify that:
|
||||
|
||||
1. Your model API can handle double messages, or the integration should
|
||||
merge messages before sending them to the API.
|
||||
merge messages before sending them to the API.
|
||||
2. The response is a valid `langchain_core.messages.AIMessage`
|
||||
|
||||
"""
|
||||
@@ -993,7 +999,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
"""Test to verify that the model returns correct usage metadata.
|
||||
|
||||
This test is optional and should be skipped if the model does not return
|
||||
usage metadata (see Configuration below).
|
||||
usage metadata (see configuration below).
|
||||
|
||||
!!! warning "Behavior changed in 0.3.17"
|
||||
Additionally check for the presence of `model_name` in the response
|
||||
@@ -1014,9 +1020,10 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
```
|
||||
|
||||
This test can also check the format of specific kinds of usage metadata
|
||||
based on the `supported_usage_metadata_details` property. This property
|
||||
should be configured as follows with the types of tokens that the model
|
||||
supports tracking:
|
||||
based on the `supported_usage_metadata_details` property.
|
||||
|
||||
This property should be configured as follows with the types of tokens that
|
||||
the model supports tracking:
|
||||
|
||||
```python
|
||||
class TestMyChatModelIntegration(ChatModelIntegrationTests):
|
||||
@@ -1186,9 +1193,10 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
```
|
||||
|
||||
This test can also check the format of specific kinds of usage metadata
|
||||
based on the `supported_usage_metadata_details` property. This property
|
||||
should be configured as follows with the types of tokens that the model
|
||||
supports tracking:
|
||||
based on the `supported_usage_metadata_details` property.
|
||||
|
||||
This property should be configured as follows with the types of tokens that
|
||||
the model supports tracking:
|
||||
|
||||
```python
|
||||
class TestMyChatModelIntegration(ChatModelIntegrationTests):
|
||||
@@ -1370,11 +1378,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
set to `False`.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
tool calling (see Configuration below).
|
||||
tool calling (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable tool calling tests, set `has_tool_calling` to False in your
|
||||
To disable tool calling tests, set `has_tool_calling` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -1432,11 +1440,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
set to `False`.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
tool calling (see Configuration below).
|
||||
tool calling (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable tool calling tests, set `has_tool_calling` to False in your
|
||||
To disable tool calling tests, set `has_tool_calling` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -1495,11 +1503,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
on the test class is set to `False`.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
tool calling (see Configuration below).
|
||||
tool calling (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable tool calling tests, set `has_tool_calling` to False in your
|
||||
To disable tool calling tests, set `has_tool_calling` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -1565,11 +1573,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
with messages generated from providers following OpenAI format.
|
||||
|
||||
This test should be skipped if the model does not support tool calling
|
||||
(see Configuration below).
|
||||
(see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable tool calling tests, set `has_tool_calling` to False in your
|
||||
To disable tool calling tests, set `has_tool_calling` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -1654,11 +1662,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
```
|
||||
|
||||
This test should be skipped if the model does not support tool calling
|
||||
(see Configuration below).
|
||||
(see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable tool calling tests, set `has_tool_calling` to False in your
|
||||
To disable tool calling tests, set `has_tool_calling` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -1734,11 +1742,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
test class is set to `False`.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
tool calling (see Configuration below).
|
||||
tool calling (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable tool calling tests, set `has_tool_choice` to False in your
|
||||
To disable tool calling tests, set `has_tool_choice` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -1786,11 +1794,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
is set to `False`.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
tool calling (see Configuration below).
|
||||
tool calling (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable tool calling tests, set `has_tool_calling` to False in your
|
||||
To disable tool calling tests, set `has_tool_calling` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -1859,11 +1867,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
to the model.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
tool calling (see Configuration below).
|
||||
tool calling (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable tool calling tests, set `has_tool_calling` to False in your
|
||||
To disable tool calling tests, set `has_tool_calling` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -1920,11 +1928,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
- `HumanMessage` with string content (a follow-up question).
|
||||
|
||||
This test should be skipped if the model does not support tool calling
|
||||
(see Configuration below).
|
||||
(see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable tool calling tests, set `has_tool_calling` to False in your
|
||||
To disable tool calling tests, set `has_tool_calling` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -1981,7 +1989,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
"""Test to verify structured output is generated both on invoke and stream.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
structured output (see Configuration below).
|
||||
structured output (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
@@ -2064,7 +2072,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
"""Test to verify structured output is generated both on invoke and stream.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
structured output (see Configuration below).
|
||||
structured output (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
@@ -2146,7 +2154,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
`pydantic.v1.BaseModel` is available in the Pydantic 2 package.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
structured output (see Configuration below).
|
||||
structured output (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
@@ -2212,7 +2220,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
parameters.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
structured output (see Configuration below).
|
||||
structured output (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
@@ -2284,11 +2292,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
"""Test structured output via [JSON mode.](https://python.langchain.com/docs/concepts/structured_outputs/#json-mode).
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
the JSON mode feature (see Configuration below).
|
||||
the JSON mode feature (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable this test, set `supports_json_mode` to False in your
|
||||
To disable this test, set `supports_json_mode` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -2343,7 +2351,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
def test_pdf_inputs(self, model: BaseChatModel) -> None:
|
||||
"""Test that the model can process PDF inputs.
|
||||
|
||||
This test should be skipped (see Configuration below) if the model does not
|
||||
This test should be skipped (see configuration below) if the model does not
|
||||
support PDF inputs. These will take the shape of the LangChain
|
||||
`FileContentBlock`:
|
||||
|
||||
@@ -2372,7 +2380,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable this test, set `supports_pdf_inputs` to False in your
|
||||
To disable this test, set `supports_pdf_inputs` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -2386,7 +2394,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
If this test fails, check that the model can correctly handle messages
|
||||
with pdf content blocks, including base64-encoded files. Otherwise, set
|
||||
the `supports_pdf_inputs` property to False.
|
||||
the `supports_pdf_inputs` property to `False`.
|
||||
|
||||
"""
|
||||
if not self.supports_pdf_inputs:
|
||||
@@ -2431,7 +2439,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
def test_audio_inputs(self, model: BaseChatModel) -> None:
|
||||
"""Test that the model can process audio inputs.
|
||||
|
||||
This test should be skipped (see Configuration below) if the model does not
|
||||
This test should be skipped (see configuration below) if the model does not
|
||||
support audio inputs. These will take the shape of the LangChain
|
||||
`AudioContentBlock`:
|
||||
|
||||
@@ -2468,7 +2476,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable this test, set `supports_audio_inputs` to False in your
|
||||
To disable this test, set `supports_audio_inputs` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -2482,7 +2490,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
If this test fails, check that the model can correctly handle messages
|
||||
with audio content blocks, specifically base64-encoded files. Otherwise,
|
||||
set the `supports_audio_inputs` property to False.
|
||||
set the `supports_audio_inputs` property to `False`.
|
||||
|
||||
""" # noqa: E501
|
||||
if not self.supports_audio_inputs:
|
||||
@@ -2526,7 +2534,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
def test_image_inputs(self, model: BaseChatModel) -> None:
|
||||
"""Test that the model can process image inputs.
|
||||
|
||||
This test should be skipped (see Configuration below) if the model does not
|
||||
This test should be skipped (see configuration below) if the model does not
|
||||
support image inputs. These will take the shape of the LangChain
|
||||
`ImageContentBlock`:
|
||||
|
||||
@@ -2553,7 +2561,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
See https://python.langchain.com/docs/concepts/multimodality/
|
||||
|
||||
If the property `supports_image_urls` is set to True, the test will also
|
||||
If the property `supports_image_urls` is set to `True`, the test will also
|
||||
check that we can process content blocks of the form:
|
||||
|
||||
```python
|
||||
@@ -2565,7 +2573,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable this test, set `supports_image_inputs` to False in your
|
||||
To disable this test, set `supports_image_inputs` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -2584,7 +2592,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
If this test fails, check that the model can correctly handle messages
|
||||
with image content blocks, including base64-encoded images. Otherwise, set
|
||||
the `supports_image_inputs` property to False.
|
||||
the `supports_image_inputs` property to `False`.
|
||||
|
||||
"""
|
||||
if not self.supports_image_inputs:
|
||||
@@ -2671,11 +2679,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
```
|
||||
|
||||
This test can be skipped by setting the `supports_image_tool_message` property
|
||||
to False (see Configuration below).
|
||||
to False (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable this test, set `supports_image_tool_message` to False in your
|
||||
To disable this test, set `supports_image_tool_message` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -2771,11 +2779,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
```
|
||||
|
||||
This test can be skipped by setting the `supports_pdf_tool_message` property
|
||||
to False (see Configuration below).
|
||||
to False (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable this test, set `supports_pdf_tool_message` to False in your
|
||||
To disable this test, set `supports_pdf_tool_message` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -2854,7 +2862,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
)
|
||||
```
|
||||
|
||||
as well as `HumanMessage` objects containing `tool_result` content blocks:
|
||||
...as well as `HumanMessage` objects containing `tool_result` content blocks:
|
||||
|
||||
```python
|
||||
HumanMessage(
|
||||
@@ -2881,7 +2889,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable this test, set `supports_anthropic_inputs` to False in your
|
||||
To disable this test, set `supports_anthropic_inputs` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
@@ -2903,7 +2911,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
handled.
|
||||
|
||||
Otherwise, if Anthropic tool call and result formats are not supported,
|
||||
set the `supports_anthropic_inputs` property to False.
|
||||
set the `supports_anthropic_inputs` property to `False`.
|
||||
|
||||
"""
|
||||
if not self.supports_anthropic_inputs:
|
||||
@@ -3047,11 +3055,11 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
set to `False`.
|
||||
|
||||
This test is optional and should be skipped if the model does not support
|
||||
tool calling (see Configuration below).
|
||||
tool calling (see configuration below).
|
||||
|
||||
??? note "Configuration"
|
||||
|
||||
To disable tool calling tests, set `has_tool_calling` to False in your
|
||||
To disable tool calling tests, set `has_tool_calling` to `False` in your
|
||||
test class:
|
||||
|
||||
```python
|
||||
|
||||
@@ -65,7 +65,7 @@ class EmbeddingsIntegrationTests(EmbeddingsTests):
|
||||
If this test fails, check that:
|
||||
|
||||
1. The model will generate a list of lists of floats when calling
|
||||
`.embed_documents` on a list of strings.
|
||||
`embed_documents` on a list of strings.
|
||||
2. The length of each list is the same.
|
||||
"""
|
||||
documents = ["foo", "bar", "baz"]
|
||||
@@ -84,7 +84,7 @@ class EmbeddingsIntegrationTests(EmbeddingsTests):
|
||||
|
||||
If this test fails, check that:
|
||||
|
||||
1. The model will generate a list of floats when calling `.aembed_query`
|
||||
1. The model will generate a list of floats when calling `aembed_query`
|
||||
on a string.
|
||||
2. The length of the list is consistent across different inputs.
|
||||
"""
|
||||
@@ -106,7 +106,7 @@ class EmbeddingsIntegrationTests(EmbeddingsTests):
|
||||
If this test fails, check that:
|
||||
|
||||
1. The model will generate a list of lists of floats when calling
|
||||
`.aembed_documents` on a list of strings.
|
||||
`aembed_documents` on a list of strings.
|
||||
2. The length of each list is the same.
|
||||
"""
|
||||
documents = ["foo", "bar", "baz"]
|
||||
|
||||
@@ -72,13 +72,13 @@ class RetrieversIntegrationTests(BaseStandardTests):
|
||||
of documents ( of the one set in `num_results_arg_name`) when it is
|
||||
set.
|
||||
|
||||
For example, a retriever like
|
||||
For example, a retriever like...
|
||||
|
||||
```python
|
||||
MyRetriever(k=3).invoke("query")
|
||||
```
|
||||
|
||||
should return 3 documents when invoked with a query.
|
||||
...should return 3 documents when invoked with a query.
|
||||
|
||||
"""
|
||||
params = {
|
||||
@@ -128,13 +128,13 @@ class RetrieversIntegrationTests(BaseStandardTests):
|
||||
of documents (`k` of the one set in `num_results_arg_name`) when it is
|
||||
set.
|
||||
|
||||
For example, a retriever like
|
||||
For example, a retriever like...
|
||||
|
||||
```python
|
||||
MyRetriever().invoke("query", k=3)
|
||||
```
|
||||
|
||||
should return 3 documents when invoked with a query.
|
||||
...should return 3 documents when invoked with a query.
|
||||
|
||||
"""
|
||||
result_1 = retriever.invoke(
|
||||
@@ -169,8 +169,8 @@ class RetrieversIntegrationTests(BaseStandardTests):
|
||||
async def test_ainvoke_returns_documents(self, retriever: BaseRetriever) -> None:
|
||||
"""Test ainvoke returns documents.
|
||||
|
||||
If ainvoked with the example params, the retriever should return a list of
|
||||
Documents.
|
||||
If `ainvoke`'d with the example params, the retriever should return a list of
|
||||
`Document` objects.
|
||||
|
||||
See `test_invoke_returns_documents` for more information on
|
||||
troubleshooting.
|
||||
|
||||
@@ -16,12 +16,12 @@ class ToolsIntegrationTests(ToolsTests):
|
||||
content.
|
||||
|
||||
If you have followed the [custom tool guide](https://python.langchain.com/docs/how_to/custom_tools/),
|
||||
this test should always pass because ToolCall inputs are handled by the
|
||||
this test should always pass because `ToolCall` inputs are handled by the
|
||||
`langchain_core.tools.BaseTool` class.
|
||||
|
||||
If you have not followed this guide, you should ensure that your tool's
|
||||
`invoke` method returns a valid ToolMessage content when it receives
|
||||
a dict representing a ToolCall as input (as opposed to distinct args).
|
||||
a `dict` representing a `ToolCall` as input (as opposed to distinct args).
|
||||
"""
|
||||
tool_call = ToolCall(
|
||||
name=tool.name,
|
||||
@@ -79,7 +79,7 @@ class ToolsIntegrationTests(ToolsTests):
|
||||
in `tool_invoke_params_example` correctly, and it's throwing an error.
|
||||
|
||||
This test doesn't have any checks. It's just to ensure that the tool
|
||||
doesn't throw an error when invoked with a dictionary of kwargs.
|
||||
doesn't throw an error when invoked with a `dict` of `**kwargs`.
|
||||
"""
|
||||
tool.invoke(self.tool_invoke_params_example)
|
||||
|
||||
|
||||
@@ -101,9 +101,9 @@ class VectorStoreIntegrationTests(BaseStandardTests):
|
||||
@abstractmethod
|
||||
@pytest.fixture
|
||||
def vectorstore(self) -> VectorStore:
|
||||
"""Get the VectorStore class to test.
|
||||
"""Get the `VectorStore` class to test.
|
||||
|
||||
The returned VectorStore should be empty.
|
||||
The returned `VectorStore` should be empty.
|
||||
"""
|
||||
|
||||
@property
|
||||
@@ -118,7 +118,7 @@ class VectorStoreIntegrationTests(BaseStandardTests):
|
||||
|
||||
@property
|
||||
def has_get_by_ids(self) -> bool:
|
||||
"""Whether the vector store supports get_by_ids."""
|
||||
"""Whether the `VectorStore` supports `get_by_ids`."""
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
@@ -137,7 +137,7 @@ class VectorStoreIntegrationTests(BaseStandardTests):
|
||||
)
|
||||
|
||||
def test_vectorstore_is_empty(self, vectorstore: VectorStore) -> None:
|
||||
"""Test that the VectorStore is empty.
|
||||
"""Test that the `VectorStore` is empty.
|
||||
|
||||
??? note "Troubleshooting"
|
||||
|
||||
@@ -159,7 +159,7 @@ class VectorStoreIntegrationTests(BaseStandardTests):
|
||||
|
||||
1. We correctly initialize an empty vector store in the `vectorestore`
|
||||
fixture.
|
||||
2. Calling `.similarity_search` for the top `k` similar documents does
|
||||
2. Calling `similarity_search` for the top `k` similar documents does
|
||||
not threshold by score.
|
||||
3. We do not mutate the original document object when adding it to the
|
||||
vector store (e.g., by adding an ID).
|
||||
@@ -185,7 +185,7 @@ class VectorStoreIntegrationTests(BaseStandardTests):
|
||||
]
|
||||
|
||||
def test_vectorstore_still_empty(self, vectorstore: VectorStore) -> None:
|
||||
"""Test that the VectorStore is still empty.
|
||||
"""Test that the `VectorStore` is still empty.
|
||||
|
||||
This test should follow a test that adds documents.
|
||||
|
||||
@@ -288,7 +288,7 @@ class VectorStoreIntegrationTests(BaseStandardTests):
|
||||
]
|
||||
|
||||
def test_add_documents_by_id_with_mutation(self, vectorstore: VectorStore) -> None:
|
||||
"""Test that we can overwrite by ID using add_documents.
|
||||
"""Test that we can overwrite by ID using `add_documents`.
|
||||
|
||||
??? note "Troubleshooting"
|
||||
|
||||
@@ -485,7 +485,7 @@ class VectorStoreIntegrationTests(BaseStandardTests):
|
||||
)
|
||||
|
||||
async def test_vectorstore_is_empty_async(self, vectorstore: VectorStore) -> None:
|
||||
"""Test that the VectorStore is empty.
|
||||
"""Test that the `VectorStore` is empty.
|
||||
|
||||
??? note "Troubleshooting"
|
||||
|
||||
@@ -536,7 +536,7 @@ class VectorStoreIntegrationTests(BaseStandardTests):
|
||||
async def test_vectorstore_still_empty_async(
|
||||
self, vectorstore: VectorStore
|
||||
) -> None:
|
||||
"""Test that the VectorStore is still empty.
|
||||
"""Test that the `VectorStore` is still empty.
|
||||
|
||||
This test should follow a test that adds documents.
|
||||
|
||||
@@ -643,7 +643,7 @@ class VectorStoreIntegrationTests(BaseStandardTests):
|
||||
async def test_add_documents_by_id_with_mutation_async(
|
||||
self, vectorstore: VectorStore
|
||||
) -> None:
|
||||
"""Test that we can overwrite by ID using add_documents.
|
||||
"""Test that we can overwrite by ID using `add_documents`.
|
||||
|
||||
??? note "Troubleshooting"
|
||||
|
||||
|
||||
@@ -185,7 +185,6 @@ class ChatModelTests(BaseStandardTests):
|
||||
Whether the chat model supports video inputs, defaults to `False`.
|
||||
|
||||
No current tests are written for this feature.
|
||||
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -210,7 +209,6 @@ class ChatModelTests(BaseStandardTests):
|
||||
|
||||
Whether the chat model supports `ToolMessage` objects that include image
|
||||
content.
|
||||
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -220,7 +218,6 @@ class ChatModelTests(BaseStandardTests):
|
||||
|
||||
Whether the chat model supports `ToolMessage` objects that include PDF
|
||||
content.
|
||||
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -231,7 +228,6 @@ class ChatModelTests(BaseStandardTests):
|
||||
!!! warning
|
||||
See `enable_vcr_tests` dropdown `above <ChatModelTests>` for more
|
||||
information.
|
||||
|
||||
"""
|
||||
return False
|
||||
|
||||
@@ -382,7 +378,9 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
??? info "`structured_output_kwargs`"
|
||||
|
||||
Dict property that can be used to specify additional kwargs for
|
||||
`with_structured_output`. Useful for testing different models.
|
||||
`with_structured_output`.
|
||||
|
||||
Useful for testing different models.
|
||||
|
||||
```python
|
||||
@property
|
||||
@@ -529,7 +527,9 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
|
||||
Boolean property indicating whether the chat model supports image inputs.
|
||||
|
||||
Defaults to `False`. No current tests are written for this feature.
|
||||
Defaults to `False`.
|
||||
|
||||
No current tests are written for this feature.
|
||||
|
||||
??? info "`returns_usage_metadata`"
|
||||
|
||||
@@ -786,7 +786,7 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
gunzip -k /path/to/tests/cassettes/TestClass_test.yaml.gz
|
||||
```
|
||||
|
||||
or by using the serializer:
|
||||
...or by using the serializer:
|
||||
|
||||
```python
|
||||
from langchain_tests.conftest import (
|
||||
|
||||
Reference in New Issue
Block a user