The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
[simple] added test case and improve self class return type annotation (#3773)
Mike Wangce4fea983bd2
diff --git a/langchain/retrievers/document_compressors/chain_extract.py b/langchain/retrievers/document_compressors/chain_extract.pyindex 175dd76d8e..db4b5a678a 100644--- a/langchain/retrievers/document_compressors/chain_extract.py+++ b/langchain/retrievers/document_compressors/chain_extract.py@@ -1,4 +1,6 @@"""DocumentFilter that uses an LLM chain to extract the relevant parts of documents."""+from __future__ import annotations+from typing import Any, Callable, Dict, Optional, Sequencefrom langchain import LLMChain, PromptTemplate@@ -70,7 +72,7 @@ class LLMChainExtractor(BaseDocumentCompressor):prompt: Optional[PromptTemplate] = None,get_input: Optional[Callable[[str, Document], str]] = None,llm_chain_kwargs: Optional[dict] = None,- ) -> "LLMChainExtractor":+ ) -> LLMChainExtractor:"""Initialize from LLM."""_prompt = prompt if prompt is not None else _get_default_chain_prompt()_get_input = get_input if get_input is not None else default_get_inputdiff --git a/tests/integration_tests/retrievers/document_compressors/test_chain_extract.py b/tests/integration_tests/retrievers/document_compressors/test_chain_extract.pyindex 0fcfebf9c6..7434f665dc 100644--- a/tests/integration_tests/retrievers/document_compressors/test_chain_extract.py+++ b/tests/integration_tests/retrievers/document_compressors/test_chain_extract.py@@ -4,6 +4,14 @@ from langchain.retrievers.document_compressors import LLMChainExtractorfrom langchain.schema import Document+def test_llm_construction_with_kwargs() -> None:+ llm_chain_kwargs = {"verbose": True}+ compressor = LLMChainExtractor.from_llm(+ ChatOpenAI(), llm_chain_kwargs=llm_chain_kwargs+ )+ assert compressor.llm_chain.verbose is True++def test_llm_chain_extractor() -> None:texts = ["The Roman Empire followed the Roman Republic.",