test_stop_sequence() — langchain Function Reference
Architecture documentation for the test_stop_sequence() function in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5011ea30_0807_be85_a58d_8611d0aa41af["test_stop_sequence()"] 971e928f_9c9b_ce7a_b93d_e762f2f5aa54["ChatModelIntegrationTests"] 5011ea30_0807_be85_a58d_8611d0aa41af -->|defined in| 971e928f_9c9b_ce7a_b93d_e762f2f5aa54 style 5011ea30_0807_be85_a58d_8611d0aa41af fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/standard-tests/langchain_tests/integration_tests/chat_models.py lines 1514–1550
def test_stop_sequence(self, model: BaseChatModel) -> None:
"""Test that model does not fail when invoked with the `stop` parameter.
The `stop` parameter is a standard parameter for stopping generation at a
certain token.
[More on standard parameters](https://python.langchain.com/docs/concepts/chat_models/#standard-parameters).
This should pass for all integrations.
??? question "Troubleshooting"
If this test fails, check that the function signature for `_generate`
(as well as `_stream` and async variants) accepts the `stop` parameter:
```python
def _generate(
self,
messages: List[BaseMessage],
stop: list[str] | None = None,
run_manager: CallbackManagerForLLMRun | None = None,
**kwargs: Any,
) -> ChatResult:
```
"""
result = model.invoke("hi", stop=["you"])
assert isinstance(result, AIMessage)
custom_model = self.chat_model_class(
**{
**self.chat_model_params,
"stop": ["you"],
}
)
result = custom_model.invoke("hi")
assert isinstance(result, AIMessage)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_stop_sequence() do?
test_stop_sequence() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py.
Where is test_stop_sequence() defined?
test_stop_sequence() is defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py at line 1514.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free