Skip to content

The agent engineering platform.

docs(standard-tests): add clarity to docstrings (#33218)

Mason Daugherty9c9b80c70a5d
diff --git a/libs/standard-tests/langchain_tests/integration_tests/chat_models.py b/libs/standard-tests/langchain_tests/integration_tests/chat_models.py
index c237c4ed8c..d635086eae 100644
--- a/libs/standard-tests/langchain_tests/integration_tests/chat_models.py
+++ b/libs/standard-tests/langchain_tests/integration_tests/chat_models.py
@@ -309,8 +309,8 @@ class ChatModelIntegrationTests(ChatModelTests):
Boolean property indicating whether the chat model supports image inputs.
Defaults to ``False``.
- If set to ``True``, the chat model will be tested using content blocks of the
- form
+ If set to ``True``, the chat model will be tested by inputting an
+ `ImageContentBlock` with the shape:
.. code-block:: python
@@ -369,8 +369,8 @@ class ChatModelIntegrationTests(ChatModelTests):
Boolean property indicating whether the chat model supports PDF inputs.
Defaults to ``False``.
- If set to ``True``, the chat model will be tested using content blocks of the
- form
+ If set to ``True``, the chat model will be tested by inputting a
+ `FileContentBlock` with the shape:
.. code-block:: python
@@ -395,8 +395,8 @@ class ChatModelIntegrationTests(ChatModelTests):
Boolean property indicating whether the chat model supports audio inputs.
Defaults to ``False``.
- If set to ``True``, the chat model will be tested using content blocks of the
- form
+ If set to ``True``, the chat model will be tested by inputting an
+ `AudioContentBlock` with the shape:
.. code-block:: python
@@ -473,8 +473,8 @@ class ChatModelIntegrationTests(ChatModelTests):
.. dropdown:: supports_image_tool_message
- Boolean property indicating whether the chat model supports ToolMessages
- that include image content, e.g.,
+ Boolean property indicating whether the chat model supports a `ToolMessage`
+ that includes image content, e.g. in the OpenAI Chat Completions format:
.. code-block:: python
@@ -489,7 +489,7 @@ class ChatModelIntegrationTests(ChatModelTests):
name="random_image",
)
- (OpenAI Chat Completions format), as well as
+ as well as the LangChain `ImageContentBlock` format:
.. code-block:: python
@@ -505,7 +505,6 @@ class ChatModelIntegrationTests(ChatModelTests):
name="random_image",
)
- (standard format).
If set to ``True``, the chat model will be tested with message sequences that
include ToolMessages of this form.
@@ -520,8 +519,8 @@ class ChatModelIntegrationTests(ChatModelTests):
.. dropdown:: supports_pdf_tool_message
- Boolean property indicating whether the chat model supports ToolMessages
- that include PDF content, i.e.,
+ Boolean property indicating whether the chat model supports a `ToolMessage
+ that include PDF content using the LangChain `FileContentBlock` format:
.. code-block:: python
@@ -537,8 +536,6 @@ class ChatModelIntegrationTests(ChatModelTests):
name="random_pdf",
)
- (standard format).
-
If set to ``True``, the chat model will be tested with message sequences that
include ToolMessages of this form.
@@ -2362,7 +2359,8 @@ class ChatModelIntegrationTests(ChatModelTests):
"""Test that the model can process PDF inputs.
This test should be skipped (see Configuration below) if the model does not
- support PDF inputs. These will take the form:
+ support PDF inputs. These will take the shape of the LangChain
+ `FileContentBlock`:
.. code-block:: python
@@ -2372,7 +2370,20 @@ class ChatModelIntegrationTests(ChatModelTests):
"mime_type": "application/pdf",
}
- See https://python.langchain.com/docs/concepts/multimodality/
+ Furthermore, for backward-compatibility, we must also support OpenAI chat
+ completions file content blocks:
+
+ .. code-block:: python
+
+ (
+ {
+ "type": "file",
+ "file": {
+ "filename": "test_file.pdf",
+ "file_data": f"data:application/pdf;base64,{pdf_data}",
+ },
+ },
+ )
.. dropdown:: Configuration
@@ -2407,8 +2418,8 @@ class ChatModelIntegrationTests(ChatModelTests):
},
{
"type": "file",
- "mime_type": "application/pdf",
"base64": pdf_data,
+ "mime_type": "application/pdf",
},
]
)
@@ -2424,7 +2435,7 @@ class ChatModelIntegrationTests(ChatModelTests):
{
"type": "file",
"file": {
- "filename": "test file.pdf",
+ "filename": "test_file.pdf",
"file_data": f"data:application/pdf;base64,{pdf_data}",
},
},
@@ -2436,7 +2447,8 @@ class ChatModelIntegrationTests(ChatModelTests):
"""Test that the model can process audio inputs.
This test should be skipped (see Configuration below) if the model does not
- support audio inputs. These will take the form:
+ support audio inputs. These will take the shape of the LangChain
+ `AudioContentBlock`:
.. code-block:: python
@@ -2446,7 +2458,18 @@ class ChatModelIntegrationTests(ChatModelTests):
"mime_type": "audio/wav", # or appropriate mime-type
}
- See https://python.langchain.com/docs/concepts/multimodality/
+ Furthermore, for backward-compatibility, we must also support OpenAI chat
+ completions audio content blocks:
+
+ .. code-block:: python
+
+ {
+ "type": "input_audio",
+ "input_audio": {
+ "data": "<base64 audio data>",
+ "format": "wav", # or appropriate format
+ },
+ }
.. dropdown:: Configuration
@@ -2507,7 +2530,8 @@ class ChatModelIntegrationTests(ChatModelTests):
"""Test that the model can process image inputs.
This test should be skipped (see Configuration below) if the model does not
- support image inputs. These will take the form:
+ support image inputs. These will take the shape of the LangChain
+ `ImageContentBlock`:
.. code-block:: python
@@ -2517,8 +2541,8 @@ class ChatModelIntegrationTests(ChatModelTests):
"mime_type": "image/jpeg", # or appropriate mime-type
}
- For backward-compatibility, we must also support OpenAI-style
- image content blocks:
+ For backward-compatibility, we must also support OpenAI chat completions
+ image content blocks containing base64-encoded images:
.. code-block:: python
@@ -2572,7 +2596,7 @@ class ChatModelIntegrationTests(ChatModelTests):
image_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
image_data = base64.b64encode(httpx.get(image_url).content).decode("utf-8")
- # OpenAI format, base64 data
+ # OpenAI CC format, base64 data
message = HumanMessage(
content=[
{"type": "text", "text": "describe the weather in this image"},
@@ -2584,14 +2608,14 @@ class ChatModelIntegrationTests(ChatModelTests):
)
_ = model.invoke([message])
- # Standard format, base64 data
+ # Standard LangChain format, base64 data
message = HumanMessage(
content=[
{"type": "text", "text": "describe the weather in this image"},
{
"type": "image",
- "mime_type": "image/jpeg",
"base64": image_data,
+ "mime_type": "image/jpeg",
},
],
)
@@ -2614,7 +2638,7 @@ class ChatModelIntegrationTests(ChatModelTests):
"""Test that the model can process ToolMessages with image inputs.
This test should be skipped if the model does not support messages of the
- form:
+ Chat Completions `image_url` format:
.. code-block:: python
@@ -2629,8 +2653,8 @@ class ChatModelIntegrationTests(ChatModelTests):
name="random_image",
)
- containing image content blocks in OpenAI Chat Completions format, in addition
- to messages of the form:
+ In addition, models should support the standard LangChain `ImageContentBlock`
+ format:
.. code-block:: python
@@ -2646,8 +2670,6 @@ class ChatModelIntegrationTests(ChatModelTests):
name="random_image",
)
- containing image content blocks in standard format.
-
This test can be skipped by setting the ``supports_image_tool_message`` property
to False (see Configuration below).
@@ -2677,7 +2699,7 @@ class ChatModelIntegrationTests(ChatModelTests):
image_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
image_data = base64.b64encode(httpx.get(image_url).content).decode("utf-8")
- # Support both OpenAI and standard formats
+ # OpenAI CC format, base64 data
oai_format_message = ToolMessage(
content=[
{
@@ -2689,6 +2711,7 @@ class ChatModelIntegrationTests(ChatModelTests):
name="random_image",
)
+ # Standard LangChain format, base64 data
standard_format_message = ToolMessage(
content=[
{
@@ -2730,7 +2753,7 @@ class ChatModelIntegrationTests(ChatModelTests):
"""Test that the model can process ToolMessages with PDF inputs.
This test should be skipped if the model does not support messages of the
- form:
+ LangChain `FileContentBlock` format:
.. code-block:: python
@@ -2746,8 +2769,6 @@ class ChatModelIntegrationTests(ChatModelTests):
name="random_pdf",
)
- containing PDF content blocks in standard format.
-
This test can be skipped by setting the ``supports_pdf_tool_message`` property
to False (see Configuration below).
diff --git a/libs/standard-tests/langchain_tests/unit_tests/chat_models.py b/libs/standard-tests/langchain_tests/unit_tests/chat_models.py
index 43dcf816dc..5aad436c43 100644
--- a/libs/standard-tests/langchain_tests/unit_tests/chat_models.py
+++ b/libs/standard-tests/langchain_tests/unit_tests/chat_models.py
@@ -443,8 +443,8 @@ class ChatModelUnitTests(ChatModelTests):
Boolean property indicating whether the chat model supports image inputs.
Defaults to ``False``.
- If set to ``True``, the chat model will be tested using content blocks of the
- form.
+ If set to ``True``, the chat model will be tested using the LangChain
+ `ImageContentBlock` format:
.. code-block:: python
@@ -454,7 +454,7 @@ class ChatModelUnitTests(ChatModelTests):
"mime_type": "image/jpeg", # or appropriate mime-type
}
- In addition to OpenAI-style content blocks:
+ In addition to OpenAI Chat Completions `image_url` blocks:
.. code-block:: python
@@ -503,8 +503,8 @@ class ChatModelUnitTests(ChatModelTests):
Boolean property indicating whether the chat model supports PDF inputs.
Defaults to ``False``.
- If set to ``True``, the chat model will be tested using content blocks of the
- form.
+ If set to ``True``, the chat model will be tested using the LangChain
+ `FileContentBlock` format:
.. code-block:: python
@@ -529,8 +529,8 @@ class ChatModelUnitTests(ChatModelTests):
Boolean property indicating whether the chat model supports audio inputs.
Defaults to ``False``.
- If set to ``True``, the chat model will be tested using content blocks of the
- form.
+ If set to ``True``, the chat model will be tested using the LangChain
+ `AudioContentBlock` format:
.. code-block:: python
@@ -623,7 +623,8 @@ class ChatModelUnitTests(ChatModelTests):
name="random_image",
)
- (OpenAI Chat Completions format), as well as
+ (OpenAI Chat Completions format), as well as LangChain's `ImageContentBlock`
+ format:
.. code-block:: python
@@ -671,7 +672,7 @@ class ChatModelUnitTests(ChatModelTests):
name="random_pdf",
)
- (standard format).
+ using LangChain's `FileContentBlock` format.
If set to ``True``, the chat model will be tested with message sequences that
include ToolMessages of this form.
diff --git a/libs/standard-tests/pyproject.toml b/libs/standard-tests/pyproject.toml
index 6032cc755a..d296de5c35 100644
--- a/libs/standard-tests/pyproject.toml
+++ b/libs/standard-tests/pyproject.toml
@@ -7,7 +7,7 @@ authors = [{ name = "Erick Friis", email = "[email protected]" }]
license = { text = "MIT" }
requires-python = ">=3.10.0,<4.0.0"
dependencies = [
- "langchain-core>=1.0.0a2,<2.0.0",
+ "langchain-core>=1.0.0a6,<2.0.0",
"pytest>=7.0.0,<9.0.0",
"pytest-asyncio>=0.20.0,<2.0.0",
"httpx>=0.28.1,<1.0.0",
@@ -55,9 +55,6 @@ disallow_any_generics = false
module = ["vcr.*",]
ignore_missing_imports = true
-[tool.ruff]
-target-version = "py39"
-
[tool.ruff.format]
docstring-code-format = true