mirror of
https://github.com/hwchase17/langchain.git
synced 2025-12-26 01:14:27 +00:00
style(standard-tests): refs pass (#33814)
This commit is contained in:
@@ -41,7 +41,7 @@ class SyncCacheTestSuite(BaseStandardTests):
|
||||
return "Sample LLM string configuration."
|
||||
|
||||
def get_sample_generation(self) -> Generation:
|
||||
"""Return a sample Generation object for testing."""
|
||||
"""Return a sample `Generation` object for testing."""
|
||||
return Generation(
|
||||
text="Sample generated text.",
|
||||
generation_info={"reason": "test"},
|
||||
@@ -66,8 +66,8 @@ class SyncCacheTestSuite(BaseStandardTests):
|
||||
|
||||
This test should follow a test that updates the cache.
|
||||
|
||||
This just verifies that the fixture is set up properly to be empty
|
||||
after each test.
|
||||
This just verifies that the fixture is set up properly to be empty after each
|
||||
test.
|
||||
"""
|
||||
assert (
|
||||
cache.lookup(self.get_sample_prompt(), self.get_sample_llm_string()) is None
|
||||
@@ -95,7 +95,7 @@ class SyncCacheTestSuite(BaseStandardTests):
|
||||
assert cache.lookup(prompt, llm_string) == [generation]
|
||||
|
||||
def test_update_cache_with_multiple_generations(self, cache: BaseCache) -> None:
|
||||
"""Test updating the cache with multiple Generation objects."""
|
||||
"""Test updating the cache with multiple `Generation` objects."""
|
||||
prompt = self.get_sample_prompt()
|
||||
llm_string = self.get_sample_llm_string()
|
||||
generations = [
|
||||
@@ -113,8 +113,8 @@ class AsyncCacheTestSuite(BaseStandardTests):
|
||||
|
||||
The test suite is designed for synchronous caching layers.
|
||||
|
||||
Implementers should subclass this test suite and provide a fixture
|
||||
that returns an empty cache for each test.
|
||||
Implementers should subclass this test suite and provide a fixture that returns an
|
||||
empty cache for each test.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
@@ -134,7 +134,7 @@ class AsyncCacheTestSuite(BaseStandardTests):
|
||||
return "Sample LLM string configuration."
|
||||
|
||||
def get_sample_generation(self) -> Generation:
|
||||
"""Return a sample Generation object for testing."""
|
||||
"""Return a sample `Generation` object for testing."""
|
||||
return Generation(
|
||||
text="Sample generated text.",
|
||||
generation_info={"reason": "test"},
|
||||
@@ -160,8 +160,8 @@ class AsyncCacheTestSuite(BaseStandardTests):
|
||||
|
||||
This test should follow a test that updates the cache.
|
||||
|
||||
This just verifies that the fixture is set up properly to be empty
|
||||
after each test.
|
||||
This just verifies that the fixture is set up properly to be empty after each
|
||||
test.
|
||||
"""
|
||||
assert (
|
||||
await cache.alookup(self.get_sample_prompt(), self.get_sample_llm_string())
|
||||
@@ -196,7 +196,7 @@ class AsyncCacheTestSuite(BaseStandardTests):
|
||||
self,
|
||||
cache: BaseCache,
|
||||
) -> None:
|
||||
"""Test updating the cache with multiple Generation objects."""
|
||||
"""Test updating the cache with multiple `Generation` objects."""
|
||||
prompt = self.get_sample_prompt()
|
||||
llm_string = self.get_sample_llm_string()
|
||||
generations = [
|
||||
|
||||
@@ -173,7 +173,6 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
`chat_model_params` properties to specify what model to test and its
|
||||
initialization parameters.
|
||||
|
||||
|
||||
```python
|
||||
from typing import Type
|
||||
|
||||
@@ -217,6 +216,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
In addition, test subclasses can control what features are tested (such as tool
|
||||
calling or multi-modality) by selectively overriding the following properties.
|
||||
|
||||
Expand to see details:
|
||||
|
||||
??? info "`has_tool_calling`"
|
||||
@@ -226,9 +226,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
By default, this is determined by whether the chat model's `bind_tools` method
|
||||
is overridden. It typically does not need to be overridden on the test class.
|
||||
|
||||
Example override:
|
||||
|
||||
```python
|
||||
```python "Example override"
|
||||
@property
|
||||
def has_tool_calling(self) -> bool:
|
||||
return True
|
||||
@@ -264,9 +262,7 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
`tool_choice="any"` will force a tool call, and `tool_choice=<tool name>`
|
||||
will force a call to a specific tool.
|
||||
|
||||
Example override:
|
||||
|
||||
```python
|
||||
```python "Example override"
|
||||
@property
|
||||
def has_tool_choice(self) -> bool:
|
||||
return False
|
||||
@@ -424,15 +420,16 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
return True
|
||||
```
|
||||
|
||||
Note: this test downloads audio data from wikimedia.org. You may need to set
|
||||
the `LANGCHAIN_TESTS_USER_AGENT` environment variable to identify these
|
||||
requests, e.g.,
|
||||
!!! warning
|
||||
This test downloads audio data from wikimedia.org. You may need to set the
|
||||
`LANGCHAIN_TESTS_USER_AGENT` environment variable to identify these tests,
|
||||
e.g.,
|
||||
|
||||
```bash
|
||||
export LANGCHAIN_TESTS_USER_AGENT="CoolBot/0.0 (https://example.org/coolbot/; coolbot@example.org) generic-library/0.0"
|
||||
```
|
||||
```bash
|
||||
export LANGCHAIN_TESTS_USER_AGENT="CoolBot/0.0 (https://example.org/coolbot/; coolbot@example.org) generic-library/0.0"
|
||||
```
|
||||
|
||||
Refer to the [Wikimedia Foundation User-Agent Policy](https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy).
|
||||
Refer to the [Wikimedia Foundation User-Agent Policy](https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy).
|
||||
|
||||
??? info "`supports_video_inputs`"
|
||||
|
||||
@@ -459,8 +456,8 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
return False
|
||||
```
|
||||
|
||||
Models supporting `usage_metadata` should also return the name of the
|
||||
underlying model in the `response_metadata` of the `AIMessage`.
|
||||
Models supporting `usage_metadata` should also return the name of the underlying
|
||||
model in the `response_metadata` of the `AIMessage`.
|
||||
|
||||
??? info "`supports_anthropic_inputs`"
|
||||
|
||||
@@ -724,7 +721,6 @@ class ChatModelIntegrationTests(ChatModelTests):
|
||||
|
||||
You can then commit the cassette to your repository. Subsequent test runs
|
||||
will use the cassette instead of making HTTP calls.
|
||||
|
||||
''' # noqa: E501,D214
|
||||
|
||||
@property
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Test suite to check index implementations.
|
||||
|
||||
Standard tests for the DocumentIndex abstraction
|
||||
Standard tests for the `DocumentIndex` abstraction
|
||||
|
||||
We don't recommend implementing externally managed DocumentIndex abstractions at this
|
||||
We don't recommend implementing externally managed `DocumentIndex` abstractions at this
|
||||
time.
|
||||
"""
|
||||
|
||||
@@ -19,8 +19,8 @@ from langchain_core.indexing.base import DocumentIndex
|
||||
class DocumentIndexerTestSuite(ABC):
|
||||
"""Test suite for checking the read-write of a document index.
|
||||
|
||||
Implementers should subclass this test suite and provide a fixture
|
||||
that returns an empty index for each test.
|
||||
Implementers should subclass this test suite and provide a fixture that returns an
|
||||
empty index for each test.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
@@ -172,7 +172,7 @@ class DocumentIndexerTestSuite(ABC):
|
||||
]
|
||||
|
||||
def test_delete_no_args(self, index: DocumentIndex) -> None:
|
||||
"""Test delete with no args raises ValueError."""
|
||||
"""Test delete with no args raises `ValueError`."""
|
||||
with pytest.raises(ValueError): # noqa: PT011
|
||||
index.delete()
|
||||
|
||||
@@ -364,7 +364,7 @@ class AsyncDocumentIndexTestSuite(ABC):
|
||||
]
|
||||
|
||||
async def test_delete_no_args(self, index: DocumentIndex) -> None:
|
||||
"""Test delete with no args raises ValueError."""
|
||||
"""Test delete with no args raises `ValueError`."""
|
||||
with pytest.raises(ValueError): # noqa: PT011
|
||||
await index.adelete()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Test suite to test vectostores."""
|
||||
"""Test suite to test `VectorStore` integrations."""
|
||||
|
||||
from abc import abstractmethod
|
||||
|
||||
@@ -95,7 +95,6 @@ class VectorStoreIntegrationTests(BaseStandardTests):
|
||||
|
||||
!!! note
|
||||
API references for individual test methods include troubleshooting tips.
|
||||
|
||||
""" # noqa: E501
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@@ -304,6 +304,7 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
|
||||
In addition, test subclasses can control what features are tested (such as tool
|
||||
calling or multi-modality) by selectively overriding the following properties.
|
||||
|
||||
Expand to see details:
|
||||
|
||||
??? info "`has_tool_calling`"
|
||||
@@ -313,9 +314,7 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
By default, this is determined by whether the chat model's `bind_tools` method
|
||||
is overridden. It typically does not need to be overridden on the test class.
|
||||
|
||||
Example override:
|
||||
|
||||
```python
|
||||
```python "Example override"
|
||||
@property
|
||||
def has_tool_calling(self) -> bool:
|
||||
return True
|
||||
@@ -350,9 +349,7 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
`tool_choice="any"` will force a tool call, and `tool_choice=<tool name>`
|
||||
will force a call to a specific tool.
|
||||
|
||||
Example override:
|
||||
|
||||
```python
|
||||
```python "Example override"
|
||||
@property
|
||||
def has_tool_choice(self) -> bool:
|
||||
return False
|
||||
@@ -429,7 +426,6 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
|
||||
See https://docs.langchain.com/oss/python/langchain/models#multimodal
|
||||
|
||||
|
||||
```python
|
||||
@property
|
||||
def supports_image_inputs(self) -> bool:
|
||||
@@ -455,7 +451,6 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
|
||||
See https://docs.langchain.com/oss/python/langchain/models#multimodal
|
||||
|
||||
|
||||
```python
|
||||
@property
|
||||
def supports_image_urls(self) -> bool:
|
||||
@@ -481,7 +476,6 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
|
||||
See https://docs.langchain.com/oss/python/langchain/models#multimodal
|
||||
|
||||
|
||||
```python
|
||||
@property
|
||||
def supports_pdf_inputs(self) -> bool:
|
||||
@@ -513,15 +507,16 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
return True
|
||||
```
|
||||
|
||||
Note: this test downloads audio data from wikimedia.org. You may need to set
|
||||
the `LANGCHAIN_TESTS_USER_AGENT` environment variable to identify these
|
||||
requests, e.g.,
|
||||
!!! warning
|
||||
This test downloads audio data from wikimedia.org. You may need to set the
|
||||
`LANGCHAIN_TESTS_USER_AGENT` environment variable to identify these tests,
|
||||
e.g.,
|
||||
|
||||
```bash
|
||||
export LANGCHAIN_TESTS_USER_AGENT="CoolBot/0.0 (https://example.org/coolbot/; coolbot@example.org) generic-library/0.0"
|
||||
```
|
||||
```bash
|
||||
export LANGCHAIN_TESTS_USER_AGENT="CoolBot/0.0 (https://example.org/coolbot/; coolbot@example.org) generic-library/0.0"
|
||||
```
|
||||
|
||||
Refer to the [Wikimedia Foundation User-Agent Policy](https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy).
|
||||
Refer to the [Wikimedia Foundation User-Agent Policy](https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy).
|
||||
|
||||
??? info "`supports_video_inputs`"
|
||||
|
||||
@@ -540,6 +535,7 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
|
||||
`usage_metadata` is an optional dict attribute on `AIMessage` objects that track
|
||||
input and output tokens.
|
||||
|
||||
[See more](https://reference.langchain.com/python/langchain_core/language_models/#langchain_core.messages.ai.UsageMetadata).
|
||||
|
||||
```python
|
||||
@@ -850,7 +846,6 @@ class ChatModelUnitTests(ChatModelTests):
|
||||
},
|
||||
)
|
||||
```
|
||||
|
||||
''' # noqa: E501,D214
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user