mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 07:09:31 +00:00
langchain: use mypy strict checking with exemptions (#31018)
* Use strict checking and exclude some rules as TODOs * Fix imports not exposed in `__all__` Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
parent
eab8484a80
commit
6cd1aadf60
@ -11,7 +11,8 @@ from langchain_core.tools import BaseTool
|
|||||||
from langchain._api.deprecation import AGENT_DEPRECATION_WARNING
|
from langchain._api.deprecation import AGENT_DEPRECATION_WARNING
|
||||||
from langchain.agents.agent import AgentExecutor
|
from langchain.agents.agent import AgentExecutor
|
||||||
from langchain.agents.agent_types import AgentType
|
from langchain.agents.agent_types import AgentType
|
||||||
from langchain.agents.loading import AGENT_TO_CLASS, load_agent
|
from langchain.agents.loading import load_agent
|
||||||
|
from langchain.agents.types import AGENT_TO_CLASS
|
||||||
|
|
||||||
|
|
||||||
@deprecated(
|
@deprecated(
|
||||||
|
@ -13,11 +13,11 @@ from langchain_core.messages import (
|
|||||||
)
|
)
|
||||||
from langchain_core.prompts import BasePromptTemplate
|
from langchain_core.prompts import BasePromptTemplate
|
||||||
from langchain_core.prompts.chat import (
|
from langchain_core.prompts.chat import (
|
||||||
BaseMessagePromptTemplate,
|
|
||||||
ChatPromptTemplate,
|
ChatPromptTemplate,
|
||||||
HumanMessagePromptTemplate,
|
HumanMessagePromptTemplate,
|
||||||
MessagesPlaceholder,
|
MessagesPlaceholder,
|
||||||
)
|
)
|
||||||
|
from langchain_core.prompts.message import BaseMessagePromptTemplate
|
||||||
from langchain_core.runnables import Runnable, RunnablePassthrough
|
from langchain_core.runnables import Runnable, RunnablePassthrough
|
||||||
from langchain_core.tools import BaseTool
|
from langchain_core.tools import BaseTool
|
||||||
from langchain_core.utils.function_calling import convert_to_openai_function
|
from langchain_core.utils.function_calling import convert_to_openai_function
|
||||||
|
@ -17,11 +17,11 @@ from langchain_core.messages import (
|
|||||||
)
|
)
|
||||||
from langchain_core.prompts import BasePromptTemplate
|
from langchain_core.prompts import BasePromptTemplate
|
||||||
from langchain_core.prompts.chat import (
|
from langchain_core.prompts.chat import (
|
||||||
BaseMessagePromptTemplate,
|
|
||||||
ChatPromptTemplate,
|
ChatPromptTemplate,
|
||||||
HumanMessagePromptTemplate,
|
HumanMessagePromptTemplate,
|
||||||
MessagesPlaceholder,
|
MessagesPlaceholder,
|
||||||
)
|
)
|
||||||
|
from langchain_core.prompts.message import BaseMessagePromptTemplate
|
||||||
from langchain_core.tools import BaseTool
|
from langchain_core.tools import BaseTool
|
||||||
from pydantic import model_validator
|
from pydantic import model_validator
|
||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
|
@ -5,7 +5,7 @@ from typing import Union
|
|||||||
|
|
||||||
from langchain_core.agents import AgentAction, AgentFinish
|
from langchain_core.agents import AgentAction, AgentFinish
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
from langchain_core.output_parsers.json import parse_json_markdown
|
from langchain_core.utils.json import parse_json_markdown
|
||||||
|
|
||||||
from langchain.agents.agent import AgentOutputParser
|
from langchain.agents.agent import AgentOutputParser
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.callbacks.manager import (
|
from langchain_core.callbacks.manager import (
|
||||||
AsyncCallbackManager,
|
AsyncCallbackManager,
|
||||||
AsyncCallbackManagerForChainGroup,
|
AsyncCallbackManagerForChainGroup,
|
||||||
@ -18,7 +19,6 @@ from langchain_core.callbacks.manager import (
|
|||||||
CallbackManagerForLLMRun,
|
CallbackManagerForLLMRun,
|
||||||
CallbackManagerForRetrieverRun,
|
CallbackManagerForRetrieverRun,
|
||||||
CallbackManagerForToolRun,
|
CallbackManagerForToolRun,
|
||||||
Callbacks,
|
|
||||||
ParentRunManager,
|
ParentRunManager,
|
||||||
RunManager,
|
RunManager,
|
||||||
ahandle_event,
|
ahandle_event,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Base interfaces for tracing runs."""
|
"""Base interfaces for tracing runs."""
|
||||||
|
|
||||||
from langchain_core.tracers.base import BaseTracer, TracerException
|
from langchain_core.exceptions import TracerException
|
||||||
|
from langchain_core.tracers.base import BaseTracer
|
||||||
|
|
||||||
__all__ = ["BaseTracer", "TracerException"]
|
__all__ = ["BaseTracer", "TracerException"]
|
||||||
|
@ -27,7 +27,7 @@ from langchain_core.runnables import (
|
|||||||
ensure_config,
|
ensure_config,
|
||||||
run_in_executor,
|
run_in_executor,
|
||||||
)
|
)
|
||||||
from langchain_core.runnables.utils import create_model
|
from langchain_core.utils.pydantic import create_model
|
||||||
from pydantic import (
|
from pydantic import (
|
||||||
BaseModel,
|
BaseModel,
|
||||||
ConfigDict,
|
ConfigDict,
|
||||||
|
@ -11,7 +11,7 @@ from langchain_core.callbacks import (
|
|||||||
from langchain_core.documents import Document
|
from langchain_core.documents import Document
|
||||||
from langchain_core.prompts import BasePromptTemplate, PromptTemplate
|
from langchain_core.prompts import BasePromptTemplate, PromptTemplate
|
||||||
from langchain_core.runnables.config import RunnableConfig
|
from langchain_core.runnables.config import RunnableConfig
|
||||||
from langchain_core.runnables.utils import create_model
|
from langchain_core.utils.pydantic import create_model
|
||||||
from langchain_text_splitters import RecursiveCharacterTextSplitter, TextSplitter
|
from langchain_text_splitters import RecursiveCharacterTextSplitter, TextSplitter
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from langchain_core._api import deprecated
|
|||||||
from langchain_core.callbacks import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import Document
|
||||||
from langchain_core.runnables.config import RunnableConfig
|
from langchain_core.runnables.config import RunnableConfig
|
||||||
from langchain_core.runnables.utils import create_model
|
from langchain_core.utils.pydantic import create_model
|
||||||
from pydantic import BaseModel, ConfigDict, model_validator
|
from pydantic import BaseModel, ConfigDict, model_validator
|
||||||
|
|
||||||
from langchain.chains.combine_documents.base import BaseCombineDocumentsChain
|
from langchain.chains.combine_documents.base import BaseCombineDocumentsChain
|
||||||
|
@ -9,7 +9,7 @@ from langchain_core._api import deprecated
|
|||||||
from langchain_core.callbacks import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import Document
|
||||||
from langchain_core.runnables.config import RunnableConfig
|
from langchain_core.runnables.config import RunnableConfig
|
||||||
from langchain_core.runnables.utils import create_model
|
from langchain_core.utils.pydantic import create_model
|
||||||
from pydantic import BaseModel, ConfigDict, model_validator
|
from pydantic import BaseModel, ConfigDict, model_validator
|
||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
@ -16,10 +16,10 @@ from typing import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from langchain_core.agents import AgentAction
|
from langchain_core.agents import AgentAction
|
||||||
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.callbacks.manager import (
|
from langchain_core.callbacks.manager import (
|
||||||
AsyncCallbackManagerForChainRun,
|
AsyncCallbackManagerForChainRun,
|
||||||
CallbackManagerForChainRun,
|
CallbackManagerForChainRun,
|
||||||
Callbacks,
|
|
||||||
)
|
)
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
|
@ -6,7 +6,7 @@ import logging
|
|||||||
import re
|
import re
|
||||||
from typing import Any, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
from langchain_core.callbacks.manager import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.output_parsers import BaseOutputParser
|
from langchain_core.output_parsers import BaseOutputParser
|
||||||
from langchain_core.prompts.prompt import PromptTemplate
|
from langchain_core.prompts.prompt import PromptTemplate
|
||||||
|
@ -5,7 +5,7 @@ from collections.abc import Mapping
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
from langchain_core.callbacks.manager import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.output_parsers import BaseOutputParser
|
from langchain_core.output_parsers import BaseOutputParser
|
||||||
from langchain_core.prompts import BasePromptTemplate
|
from langchain_core.prompts import BasePromptTemplate
|
||||||
|
@ -6,10 +6,10 @@ from enum import Enum
|
|||||||
from importlib import util
|
from importlib import util
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.callbacks.manager import (
|
from langchain_core.callbacks.manager import (
|
||||||
AsyncCallbackManagerForChainRun,
|
AsyncCallbackManagerForChainRun,
|
||||||
CallbackManagerForChainRun,
|
CallbackManagerForChainRun,
|
||||||
Callbacks,
|
|
||||||
)
|
)
|
||||||
from langchain_core.embeddings import Embeddings
|
from langchain_core.embeddings import Embeddings
|
||||||
from langchain_core.utils import pre_init
|
from langchain_core.utils import pre_init
|
||||||
|
@ -7,7 +7,7 @@ import string
|
|||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from langchain_core.callbacks.manager import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.prompts import PromptTemplate
|
from langchain_core.prompts import PromptTemplate
|
||||||
from pydantic import ConfigDict
|
from pydantic import ConfigDict
|
||||||
|
@ -6,7 +6,7 @@ import logging
|
|||||||
import re
|
import re
|
||||||
from typing import Any, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
from langchain_core.callbacks.manager import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.output_parsers import BaseOutputParser
|
from langchain_core.output_parsers import BaseOutputParser
|
||||||
from langchain_core.prompts.prompt import PromptTemplate
|
from langchain_core.prompts.prompt import PromptTemplate
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Callable, Optional
|
from typing import Any, Callable, Optional
|
||||||
|
|
||||||
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.callbacks.manager import (
|
from langchain_core.callbacks.manager import (
|
||||||
AsyncCallbackManagerForChainRun,
|
AsyncCallbackManagerForChainRun,
|
||||||
CallbackManagerForChainRun,
|
CallbackManagerForChainRun,
|
||||||
Callbacks,
|
|
||||||
)
|
)
|
||||||
from langchain_core.utils import pre_init
|
from langchain_core.utils import pre_init
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from langchain_core._api import deprecated
|
from langchain_core._api import deprecated
|
||||||
|
from langchain_core.memory import BaseMemory
|
||||||
from langchain_core.messages import BaseMessage, get_buffer_string
|
from langchain_core.messages import BaseMessage, get_buffer_string
|
||||||
from langchain_core.utils import pre_init
|
from langchain_core.utils import pre_init
|
||||||
|
|
||||||
from langchain.memory.chat_memory import BaseChatMemory, BaseMemory
|
from langchain.memory.chat_memory import BaseChatMemory
|
||||||
from langchain.memory.utils import get_prompt_input_key
|
from langchain.memory.utils import get_prompt_input_key
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@ from typing import Any, Optional, Union
|
|||||||
|
|
||||||
from langchain_core._api import deprecated
|
from langchain_core._api import deprecated
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import Document
|
||||||
|
from langchain_core.memory import BaseMemory
|
||||||
from langchain_core.vectorstores import VectorStoreRetriever
|
from langchain_core.vectorstores import VectorStoreRetriever
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
|
|
||||||
from langchain.memory.chat_memory import BaseMemory
|
|
||||||
from langchain.memory.utils import get_prompt_input_key
|
from langchain.memory.utils import get_prompt_input_key
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ from langchain_core.prompt_values import ChatPromptValue, ChatPromptValueConcret
|
|||||||
from langchain_core.prompts.chat import (
|
from langchain_core.prompts.chat import (
|
||||||
AIMessagePromptTemplate,
|
AIMessagePromptTemplate,
|
||||||
BaseChatPromptTemplate,
|
BaseChatPromptTemplate,
|
||||||
BaseMessagePromptTemplate,
|
|
||||||
BaseStringMessagePromptTemplate,
|
BaseStringMessagePromptTemplate,
|
||||||
ChatMessagePromptTemplate,
|
ChatMessagePromptTemplate,
|
||||||
ChatPromptTemplate,
|
ChatPromptTemplate,
|
||||||
@ -34,3 +33,5 @@ __all__ = [
|
|||||||
"MessageLike",
|
"MessageLike",
|
||||||
"MessageLikeRepresentation",
|
"MessageLikeRepresentation",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
from langchain_core.prompts.message import BaseMessagePromptTemplate
|
||||||
|
@ -4,14 +4,10 @@ from langchain_core.callbacks import (
|
|||||||
AsyncCallbackManagerForRetrieverRun,
|
AsyncCallbackManagerForRetrieverRun,
|
||||||
CallbackManagerForRetrieverRun,
|
CallbackManagerForRetrieverRun,
|
||||||
)
|
)
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import BaseDocumentCompressor, Document
|
||||||
from langchain_core.retrievers import BaseRetriever, RetrieverLike
|
from langchain_core.retrievers import BaseRetriever, RetrieverLike
|
||||||
from pydantic import ConfigDict
|
from pydantic import ConfigDict
|
||||||
|
|
||||||
from langchain.retrievers.document_compressors.base import (
|
|
||||||
BaseDocumentCompressor,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ContextualCompressionRetriever(BaseRetriever):
|
class ContextualCompressionRetriever(BaseRetriever):
|
||||||
"""Retriever that wraps a base retriever and compresses the results."""
|
"""Retriever that wraps a base retriever and compresses the results."""
|
||||||
|
@ -34,9 +34,10 @@ def __getattr__(name: str) -> Any:
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
"DocumentCompressorPipeline",
|
"DocumentCompressorPipeline",
|
||||||
"EmbeddingsFilter",
|
"EmbeddingsFilter",
|
||||||
|
"FlashrankRerank",
|
||||||
"LLMListwiseRerank",
|
"LLMListwiseRerank",
|
||||||
"LLMChainExtractor",
|
"LLMChainExtractor",
|
||||||
"LLMChainFilter",
|
"LLMChainFilter",
|
||||||
"CohereRerank",
|
"CohereRerank",
|
||||||
"CrossEncoderReranker",
|
"CrossEncoderReranker",
|
||||||
] + list(_module_lookup.keys())
|
]
|
||||||
|
@ -2,7 +2,7 @@ from collections.abc import Sequence
|
|||||||
from inspect import signature
|
from inspect import signature
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
from langchain_core.callbacks.manager import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.documents import (
|
from langchain_core.documents import (
|
||||||
BaseDocumentCompressor,
|
BaseDocumentCompressor,
|
||||||
BaseDocumentTransformer,
|
BaseDocumentTransformer,
|
||||||
|
@ -5,8 +5,8 @@ from __future__ import annotations
|
|||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from typing import Any, Callable, Optional, cast
|
from typing import Any, Callable, Optional, cast
|
||||||
|
|
||||||
from langchain_core.callbacks.manager import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import BaseDocumentCompressor, Document
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.output_parsers import BaseOutputParser, StrOutputParser
|
from langchain_core.output_parsers import BaseOutputParser, StrOutputParser
|
||||||
from langchain_core.prompts import PromptTemplate
|
from langchain_core.prompts import PromptTemplate
|
||||||
@ -14,7 +14,6 @@ from langchain_core.runnables import Runnable
|
|||||||
from pydantic import ConfigDict
|
from pydantic import ConfigDict
|
||||||
|
|
||||||
from langchain.chains.llm import LLMChain
|
from langchain.chains.llm import LLMChain
|
||||||
from langchain.retrievers.document_compressors.base import BaseDocumentCompressor
|
|
||||||
from langchain.retrievers.document_compressors.chain_extract_prompt import (
|
from langchain.retrievers.document_compressors.chain_extract_prompt import (
|
||||||
prompt_template,
|
prompt_template,
|
||||||
)
|
)
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from typing import Any, Callable, Optional
|
from typing import Any, Callable, Optional
|
||||||
|
|
||||||
from langchain_core.callbacks.manager import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import BaseDocumentCompressor, Document
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.output_parsers import StrOutputParser
|
from langchain_core.output_parsers import StrOutputParser
|
||||||
from langchain_core.prompts import BasePromptTemplate, PromptTemplate
|
from langchain_core.prompts import BasePromptTemplate, PromptTemplate
|
||||||
@ -14,7 +14,6 @@ from pydantic import ConfigDict
|
|||||||
|
|
||||||
from langchain.chains import LLMChain
|
from langchain.chains import LLMChain
|
||||||
from langchain.output_parsers.boolean import BooleanOutputParser
|
from langchain.output_parsers.boolean import BooleanOutputParser
|
||||||
from langchain.retrievers.document_compressors.base import BaseDocumentCompressor
|
|
||||||
from langchain.retrievers.document_compressors.chain_filter_prompt import (
|
from langchain.retrievers.document_compressors.chain_filter_prompt import (
|
||||||
prompt_template,
|
prompt_template,
|
||||||
)
|
)
|
||||||
|
@ -5,13 +5,11 @@ from copy import deepcopy
|
|||||||
from typing import Any, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
from langchain_core._api.deprecation import deprecated
|
from langchain_core._api.deprecation import deprecated
|
||||||
from langchain_core.callbacks.manager import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import BaseDocumentCompressor, Document
|
||||||
from langchain_core.utils import get_from_dict_or_env
|
from langchain_core.utils import get_from_dict_or_env
|
||||||
from pydantic import ConfigDict, model_validator
|
from pydantic import ConfigDict, model_validator
|
||||||
|
|
||||||
from langchain.retrievers.document_compressors.base import BaseDocumentCompressor
|
|
||||||
|
|
||||||
|
|
||||||
@deprecated(
|
@deprecated(
|
||||||
since="0.0.30", removal="1.0", alternative_import="langchain_cohere.CohereRerank"
|
since="0.0.30", removal="1.0", alternative_import="langchain_cohere.CohereRerank"
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional
|
||||||
|
|
||||||
from langchain_core.callbacks.manager import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import BaseDocumentCompressor, Document
|
||||||
from langchain_core.embeddings import Embeddings
|
from langchain_core.embeddings import Embeddings
|
||||||
from langchain_core.utils import pre_init
|
from langchain_core.utils import pre_init
|
||||||
from pydantic import ConfigDict, Field
|
from pydantic import ConfigDict, Field
|
||||||
|
|
||||||
from langchain.retrievers.document_compressors.base import (
|
|
||||||
BaseDocumentCompressor,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _get_similarity_function() -> Callable:
|
def _get_similarity_function() -> Callable:
|
||||||
try:
|
try:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from langchain_core.runnables.base import Input, Output, RunnableBindingBase
|
from langchain_core.runnables.base import RunnableBindingBase
|
||||||
|
from langchain_core.runnables.utils import Input, Output
|
||||||
|
|
||||||
|
|
||||||
class HubRunnable(RunnableBindingBase[Input, Output]):
|
class HubRunnable(RunnableBindingBase[Input, Output]):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
from langchain_core.tracers.base import BaseTracer, TracerException
|
from langchain_core.exceptions import TracerException
|
||||||
|
from langchain_core.tracers.base import BaseTracer
|
||||||
|
|
||||||
__all__ = ["TracerException", "BaseTracer"]
|
__all__ = ["TracerException", "BaseTracer"]
|
||||||
|
@ -19,7 +19,7 @@ from typing import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from langchain_core._api import warn_deprecated
|
from langchain_core._api import warn_deprecated
|
||||||
from langchain_core.callbacks.manager import Callbacks
|
from langchain_core.callbacks import Callbacks
|
||||||
from langchain_core.language_models import BaseLanguageModel
|
from langchain_core.language_models import BaseLanguageModel
|
||||||
from langchain_core.messages import BaseMessage, messages_from_dict
|
from langchain_core.messages import BaseMessage, messages_from_dict
|
||||||
from langchain_core.outputs import ChatResult, LLMResult
|
from langchain_core.outputs import ChatResult, LLMResult
|
||||||
@ -1226,7 +1226,7 @@ class _DatasetRunContainer:
|
|||||||
|
|
||||||
def _is_jupyter_environment() -> bool:
|
def _is_jupyter_environment() -> bool:
|
||||||
try:
|
try:
|
||||||
from IPython import get_ipython
|
from IPython.core.getipython import get_ipython
|
||||||
|
|
||||||
res = get_ipython()
|
res = get_ipython()
|
||||||
return get_ipython() is not None and "zmqshell" in str(type(res))
|
return get_ipython() is not None and "zmqshell" in str(type(res))
|
||||||
|
@ -91,7 +91,7 @@ lint = [
|
|||||||
"cffi; python_version >= \"3.10\"",
|
"cffi; python_version >= \"3.10\"",
|
||||||
]
|
]
|
||||||
typing = [
|
typing = [
|
||||||
"mypy<2.0,>=1.15",
|
"mypy<1.16,>=1.15",
|
||||||
"types-pyyaml<7.0.0.0,>=6.0.12.2",
|
"types-pyyaml<7.0.0.0,>=6.0.12.2",
|
||||||
"types-requests<3.0.0.0,>=2.28.11.5",
|
"types-requests<3.0.0.0,>=2.28.11.5",
|
||||||
"types-toml<1.0.0.0,>=0.10.8.1",
|
"types-toml<1.0.0.0,>=0.10.8.1",
|
||||||
@ -124,9 +124,18 @@ target-version = "py39"
|
|||||||
exclude = ["tests/integration_tests/examples/non-utf8-encoding.py"]
|
exclude = ["tests/integration_tests/examples/non-utf8-encoding.py"]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
|
strict = "True"
|
||||||
|
strict_bytes = "True"
|
||||||
ignore_missing_imports = "True"
|
ignore_missing_imports = "True"
|
||||||
disallow_untyped_defs = "True"
|
enable_error_code = "deprecated"
|
||||||
warn_unused_ignores = "True"
|
report_deprecated_as_note = "True"
|
||||||
|
|
||||||
|
# TODO: activate for 'strict' checking
|
||||||
|
disallow_untyped_calls = "False"
|
||||||
|
disallow_any_generics = "False"
|
||||||
|
disallow_untyped_decorators = "False"
|
||||||
|
warn_return_any = "False"
|
||||||
|
strict_equality = "False"
|
||||||
|
|
||||||
[tool.codespell]
|
[tool.codespell]
|
||||||
skip = ".git,*.pdf,*.svg,*.pdf,*.yaml,*.ipynb,poetry.lock,*.min.js,*.css,package-lock.json,example_data,_dist,examples,*.trig"
|
skip = ".git,*.pdf,*.svg,*.pdf,*.yaml,*.ipynb,poetry.lock,*.min.js,*.css,package-lock.json,example_data,_dist,examples,*.trig"
|
||||||
|
@ -2,9 +2,10 @@ import pathlib
|
|||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from langchain_core.callbacks import CallbackManagerForChainRun
|
||||||
|
|
||||||
from langchain.callbacks import FileCallbackHandler
|
from langchain.callbacks import FileCallbackHandler
|
||||||
from langchain.chains.base import CallbackManagerForChainRun, Chain
|
from langchain.chains.base import Chain
|
||||||
|
|
||||||
|
|
||||||
class FakeChain(Chain):
|
class FakeChain(Chain):
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from langchain_core.callbacks import CallbackManagerForChainRun
|
||||||
|
|
||||||
from langchain.callbacks import StdOutCallbackHandler
|
from langchain.callbacks import StdOutCallbackHandler
|
||||||
from langchain.chains.base import CallbackManagerForChainRun, Chain
|
from langchain.chains.base import Chain
|
||||||
|
|
||||||
|
|
||||||
class FakeChain(Chain):
|
class FakeChain(Chain):
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from langchain_core.agents import AgentAction, BaseMessage
|
from langchain_core.agents import AgentAction
|
||||||
from langchain_core.callbacks.manager import CallbackManagerForLLMRun
|
from langchain_core.callbacks.manager import CallbackManagerForLLMRun
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
|
from langchain_core.messages import BaseMessage
|
||||||
from langchain_core.tools import tool
|
from langchain_core.tools import tool
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
|
|
||||||
|
@ -4,12 +4,13 @@ from typing import Any, Callable, Optional, TypeVar
|
|||||||
import pytest
|
import pytest
|
||||||
from langchain_core.exceptions import OutputParserException
|
from langchain_core.exceptions import OutputParserException
|
||||||
from langchain_core.messages import AIMessage
|
from langchain_core.messages import AIMessage
|
||||||
|
from langchain_core.output_parsers import BaseOutputParser
|
||||||
from langchain_core.prompts.prompt import PromptTemplate
|
from langchain_core.prompts.prompt import PromptTemplate
|
||||||
from langchain_core.runnables import Runnable, RunnableLambda, RunnablePassthrough
|
from langchain_core.runnables import Runnable, RunnableLambda, RunnablePassthrough
|
||||||
|
|
||||||
from langchain.output_parsers.boolean import BooleanOutputParser
|
from langchain.output_parsers.boolean import BooleanOutputParser
|
||||||
from langchain.output_parsers.datetime import DatetimeOutputParser
|
from langchain.output_parsers.datetime import DatetimeOutputParser
|
||||||
from langchain.output_parsers.fix import BaseOutputParser, OutputFixingParser
|
from langchain.output_parsers.fix import OutputFixingParser
|
||||||
from langchain.output_parsers.prompts import NAIVE_FIX_PROMPT
|
from langchain.output_parsers.prompts import NAIVE_FIX_PROMPT
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
@ -2,6 +2,8 @@ from datetime import datetime as dt
|
|||||||
from typing import Any, Callable, Optional, TypeVar
|
from typing import Any, Callable, Optional, TypeVar
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from langchain_core.exceptions import OutputParserException
|
||||||
|
from langchain_core.output_parsers import BaseOutputParser
|
||||||
from langchain_core.prompt_values import PromptValue, StringPromptValue
|
from langchain_core.prompt_values import PromptValue, StringPromptValue
|
||||||
from langchain_core.runnables import Runnable, RunnableLambda, RunnablePassthrough
|
from langchain_core.runnables import Runnable, RunnableLambda, RunnablePassthrough
|
||||||
|
|
||||||
@ -10,8 +12,6 @@ from langchain.output_parsers.datetime import DatetimeOutputParser
|
|||||||
from langchain.output_parsers.retry import (
|
from langchain.output_parsers.retry import (
|
||||||
NAIVE_RETRY_PROMPT,
|
NAIVE_RETRY_PROMPT,
|
||||||
NAIVE_RETRY_WITH_ERROR_PROMPT,
|
NAIVE_RETRY_WITH_ERROR_PROMPT,
|
||||||
BaseOutputParser,
|
|
||||||
OutputParserException,
|
|
||||||
RetryOutputParser,
|
RetryOutputParser,
|
||||||
RetryWithErrorOutputParser,
|
RetryWithErrorOutputParser,
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from langchain_core.retrievers import BaseRetriever, Document
|
from langchain_core.documents import Document
|
||||||
|
from langchain_core.retrievers import BaseRetriever
|
||||||
|
|
||||||
|
|
||||||
class SequentialRetriever(BaseRetriever):
|
class SequentialRetriever(BaseRetriever):
|
||||||
|
@ -2,7 +2,7 @@ from typing import Any
|
|||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from langchain_core.prompts import ChatPromptTemplate
|
from langchain_core.prompts import ChatPromptTemplate
|
||||||
from langchain_core.runnables.base import ConfigurableField
|
from langchain_core.runnables import ConfigurableField
|
||||||
|
|
||||||
from langchain.runnables.hub import HubRunnable
|
from langchain.runnables.hub import HubRunnable
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from langchain_core.language_models.chat_models import BaseChatModel
|
|||||||
from langchain_core.messages import AIMessage, BaseMessage
|
from langchain_core.messages import AIMessage, BaseMessage
|
||||||
from langchain_core.outputs import ChatGeneration, ChatResult
|
from langchain_core.outputs import ChatGeneration, ChatResult
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from syrupy import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from langchain.runnables.openai_functions import OpenAIFunctionsRouter
|
from langchain.runnables.openai_functions import OpenAIFunctionsRouter
|
||||||
|
|
||||||
|
@ -2566,7 +2566,7 @@ test-integration = [
|
|||||||
typing = [
|
typing = [
|
||||||
{ name = "langchain-core", editable = "../core" },
|
{ name = "langchain-core", editable = "../core" },
|
||||||
{ name = "langchain-text-splitters", editable = "../text-splitters" },
|
{ name = "langchain-text-splitters", editable = "../text-splitters" },
|
||||||
{ name = "mypy", specifier = ">=1.15,<2.0" },
|
{ name = "mypy", specifier = ">=1.15,<1.16" },
|
||||||
{ name = "mypy-protobuf", specifier = ">=3.0.0,<4.0.0" },
|
{ name = "mypy-protobuf", specifier = ">=3.0.0,<4.0.0" },
|
||||||
{ name = "numpy", marker = "python_full_version < '3.13'", specifier = ">=1.26.4" },
|
{ name = "numpy", marker = "python_full_version < '3.13'", specifier = ">=1.26.4" },
|
||||||
{ name = "numpy", marker = "python_full_version >= '3.13'", specifier = ">=2.1.0" },
|
{ name = "numpy", marker = "python_full_version >= '3.13'", specifier = ">=2.1.0" },
|
||||||
|
Loading…
Reference in New Issue
Block a user