langchain: Add ruff rule RUF (#31874)

All auto-fixes
See https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf

---------

Co-authored-by: Mason Daugherty <mason@langchain.dev>
This commit is contained in:
Christophe Bornet 2025-07-07 18:49:38 +02:00 committed by GitHub
parent ed35372580
commit ba144c9d7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
291 changed files with 821 additions and 830 deletions

View File

@ -1,4 +1,3 @@
# ruff: noqa: E402
"""Main entrypoint into package.""" """Main entrypoint into package."""
import warnings import warnings
@ -391,50 +390,50 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"FAISS",
"Anthropic",
"ArxivAPIWrapper",
"Banana",
"BasePromptTemplate",
"CerebriumAI",
"Cohere",
"ConversationChain",
"ElasticVectorSearch",
"FewShotPromptTemplate",
"ForefrontAI",
"GoldenQueryAPIWrapper",
"GoogleSearchAPIWrapper",
"GoogleSerperAPIWrapper",
"GooseAI",
"HuggingFaceHub",
"HuggingFacePipeline",
"HuggingFaceTextGenInference",
"InMemoryDocstore",
"LLMChain", "LLMChain",
"LLMCheckerChain", "LLMCheckerChain",
"LLMMathChain", "LLMMathChain",
"ArxivAPIWrapper", "LlamaCpp",
"GoldenQueryAPIWrapper", "MRKLChain",
"SelfAskWithSearchChain",
"SerpAPIWrapper",
"SerpAPIChain",
"SearxSearchWrapper",
"GoogleSearchAPIWrapper",
"GoogleSerperAPIWrapper",
"WolframAlphaAPIWrapper",
"WikipediaAPIWrapper",
"Anthropic",
"Banana",
"CerebriumAI",
"Cohere",
"ForefrontAI",
"GooseAI",
"Modal", "Modal",
"OpenAI", "OpenAI",
"Petals", "Petals",
"PipelineAI", "PipelineAI",
"StochasticAI",
"Writer",
"BasePromptTemplate",
"Prompt",
"FewShotPromptTemplate",
"PromptTemplate",
"ReActChain",
"Wikipedia",
"HuggingFaceHub",
"SagemakerEndpoint",
"HuggingFacePipeline",
"SQLDatabase",
"PowerBIDataset", "PowerBIDataset",
"FAISS", "Prompt",
"MRKLChain", "PromptTemplate",
"VectorDBQA",
"ElasticVectorSearch",
"InMemoryDocstore",
"ConversationChain",
"VectorDBQAWithSourcesChain",
"QAWithSourcesChain", "QAWithSourcesChain",
"LlamaCpp", "ReActChain",
"HuggingFaceTextGenInference", "SQLDatabase",
"SagemakerEndpoint",
"SearxSearchWrapper",
"SelfAskWithSearchChain",
"SerpAPIChain",
"SerpAPIWrapper",
"StochasticAI",
"VectorDBQA",
"VectorDBQAWithSourcesChain",
"Wikipedia",
"WikipediaAPIWrapper",
"WolframAlphaAPIWrapper",
"Writer",
] ]

View File

@ -19,10 +19,10 @@ from .deprecation import (
from .module_import import create_importer from .module_import import create_importer
__all__ = [ __all__ = [
"deprecated",
"LangChainDeprecationWarning", "LangChainDeprecationWarning",
"create_importer",
"deprecated",
"suppress_langchain_deprecation_warning", "suppress_langchain_deprecation_warning",
"surface_langchain_deprecation_warnings", "surface_langchain_deprecation_warnings",
"warn_deprecated", "warn_deprecated",
"create_importer",
] ]

View File

@ -15,9 +15,9 @@ AGENT_DEPRECATION_WARNING = (
"details, refer to the " "details, refer to the "
"`LangGraph documentation <https://langchain-ai.github.io/langgraph/>`_" "`LangGraph documentation <https://langchain-ai.github.io/langgraph/>`_"
" as well as guides for " " as well as guides for "
"`Migrating from AgentExecutor <https://python.langchain.com/docs/how_to/migrate_agent/>`_" # noqa: E501 "`Migrating from AgentExecutor <https://python.langchain.com/docs/how_to/migrate_agent/>`_"
" and LangGraph's " " and LangGraph's "
"`Pre-built ReAct agent <https://langchain-ai.github.io/langgraph/how-tos/create-react-agent/>`_." # noqa: E501 "`Pre-built ReAct agent <https://langchain-ai.github.io/langgraph/how-tos/create-react-agent/>`_."
) )
@ -27,6 +27,6 @@ __all__ = [
"LangChainPendingDeprecationWarning", "LangChainPendingDeprecationWarning",
"deprecated", "deprecated",
"suppress_langchain_deprecation_warning", "suppress_langchain_deprecation_warning",
"warn_deprecated",
"surface_langchain_deprecation_warnings", "surface_langchain_deprecation_warnings",
"warn_deprecated",
] ]

View File

@ -1,3 +1,3 @@
from langchain_core._api.path import as_import_path, get_relative_path from langchain_core._api.path import as_import_path, get_relative_path
__all__ = ["get_relative_path", "as_import_path"] __all__ = ["as_import_path", "get_relative_path"]

View File

@ -47,17 +47,17 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"IndexableBaseModel", "Chat",
"Choice", "ChatCompletion",
"ChatCompletions",
"ChoiceChunk",
"ChatCompletionChunk", "ChatCompletionChunk",
"ChatCompletions",
"Choice",
"ChoiceChunk",
"Completions",
"IndexableBaseModel",
"chat",
"convert_dict_to_message", "convert_dict_to_message",
"convert_message_to_dict", "convert_message_to_dict",
"convert_openai_messages",
"ChatCompletion",
"convert_messages_for_finetuning", "convert_messages_for_finetuning",
"Completions", "convert_openai_messages",
"Chat",
"chat",
] ]

View File

@ -154,29 +154,29 @@ __all__ = [
"ReActTextWorldAgent", "ReActTextWorldAgent",
"SelfAskWithSearchChain", "SelfAskWithSearchChain",
"StructuredChatAgent", "StructuredChatAgent",
"Tool",
"XMLAgent",
"ZeroShotAgent", "ZeroShotAgent",
"create_json_agent", "create_json_agent",
"create_json_chat_agent",
"create_openai_functions_agent",
"create_openai_tools_agent",
"create_openapi_agent", "create_openapi_agent",
"create_pbi_agent", "create_pbi_agent",
"create_pbi_chat_agent", "create_pbi_chat_agent",
"create_react_agent",
"create_self_ask_with_search_agent",
"create_spark_sql_agent", "create_spark_sql_agent",
"create_sql_agent", "create_sql_agent",
"create_structured_chat_agent",
"create_tool_calling_agent",
"create_vectorstore_agent", "create_vectorstore_agent",
"create_vectorstore_router_agent", "create_vectorstore_router_agent",
"create_xml_agent",
"get_all_tool_names", "get_all_tool_names",
"initialize_agent", "initialize_agent",
"load_agent", "load_agent",
"load_huggingface_tool", "load_huggingface_tool",
"load_tools", "load_tools",
"XMLAgent",
"create_openai_functions_agent",
"create_xml_agent",
"create_react_agent",
"create_openai_tools_agent",
"create_self_ask_with_search_agent",
"create_json_chat_agent",
"create_structured_chat_agent",
"create_tool_calling_agent",
"Tool",
"tool", "tool",
] ]

View File

@ -1241,7 +1241,7 @@ class AgentExecutor(Chain):
:meta private: :meta private:
""" """
if self.return_intermediate_steps: if self.return_intermediate_steps:
return self._action_agent.return_values + ["intermediate_steps"] return [*self._action_agent.return_values, "intermediate_steps"]
return self._action_agent.return_values return self._action_agent.return_values
def lookup_tool(self, name: str) -> BaseTool: def lookup_tool(self, name: str) -> BaseTool:
@ -1349,7 +1349,7 @@ class AgentExecutor(Chain):
"An output parsing error occurred. " "An output parsing error occurred. "
"In order to pass this error back to the agent and have it try " "In order to pass this error back to the agent and have it try "
"again, pass `handle_parsing_errors=True` to the AgentExecutor. " "again, pass `handle_parsing_errors=True` to the AgentExecutor. "
f"This is the error: {str(e)}" f"This is the error: {e!s}"
) )
raise ValueError(msg) raise ValueError(msg)
text = str(e) text = str(e)
@ -1485,7 +1485,7 @@ class AgentExecutor(Chain):
"An output parsing error occurred. " "An output parsing error occurred. "
"In order to pass this error back to the agent and have it try " "In order to pass this error back to the agent and have it try "
"again, pass `handle_parsing_errors=True` to the AgentExecutor. " "again, pass `handle_parsing_errors=True` to the AgentExecutor. "
f"This is the error: {str(e)}" f"This is the error: {e!s}"
) )
raise ValueError(msg) raise ValueError(msg)
text = str(e) text = str(e)

View File

@ -140,28 +140,28 @@ __all__ = [
"JiraToolkit", "JiraToolkit",
"JsonToolkit", "JsonToolkit",
"MultionToolkit", "MultionToolkit",
"NasaToolkit",
"NLAToolkit", "NLAToolkit",
"NasaToolkit",
"O365Toolkit", "O365Toolkit",
"OpenAPIToolkit", "OpenAPIToolkit",
"PlayWrightBrowserToolkit", "PlayWrightBrowserToolkit",
"PowerBIToolkit", "PowerBIToolkit",
"SlackToolkit",
"SteamToolkit",
"SQLDatabaseToolkit", "SQLDatabaseToolkit",
"SlackToolkit",
"SparkSQLToolkit", "SparkSQLToolkit",
"SteamToolkit",
"VectorStoreInfo", "VectorStoreInfo",
"VectorStoreRouterToolkit", "VectorStoreRouterToolkit",
"VectorStoreToolkit", "VectorStoreToolkit",
"ZapierToolkit", "ZapierToolkit",
"create_conversational_retrieval_agent",
"create_json_agent", "create_json_agent",
"create_openapi_agent", "create_openapi_agent",
"create_pbi_agent", "create_pbi_agent",
"create_pbi_chat_agent", "create_pbi_chat_agent",
"create_retriever_tool",
"create_spark_sql_agent", "create_spark_sql_agent",
"create_sql_agent", "create_sql_agent",
"create_vectorstore_agent", "create_vectorstore_agent",
"create_vectorstore_router_agent", "create_vectorstore_router_agent",
"create_conversational_retrieval_agent",
"create_retriever_tool",
] ]

View File

@ -51,19 +51,19 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"NoInput", "BranchName",
"GetIssue",
"CommentOnIssue", "CommentOnIssue",
"GetPR",
"CreatePR",
"CreateFile", "CreateFile",
"ReadFile", "CreatePR",
"UpdateFile", "CreateReviewRequest",
"DeleteFile", "DeleteFile",
"DirectoryPath", "DirectoryPath",
"BranchName", "GetIssue",
"SearchCode", "GetPR",
"CreateReviewRequest",
"SearchIssuesAndPRs",
"GitHubToolkit", "GitHubToolkit",
"NoInput",
"ReadFile",
"SearchCode",
"SearchIssuesAndPRs",
"UpdateFile",
] ]

View File

@ -43,10 +43,10 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"RequestsGetToolWithParsing",
"RequestsPostToolWithParsing",
"RequestsPatchToolWithParsing",
"RequestsPutToolWithParsing",
"RequestsDeleteToolWithParsing", "RequestsDeleteToolWithParsing",
"RequestsGetToolWithParsing",
"RequestsPatchToolWithParsing",
"RequestsPostToolWithParsing",
"RequestsPutToolWithParsing",
"create_openapi_agent", "create_openapi_agent",
] ]

View File

@ -83,21 +83,21 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"API_PLANNER_PROMPT",
"API_PLANNER_TOOL_NAME",
"API_PLANNER_TOOL_DESCRIPTION",
"API_CONTROLLER_PROMPT", "API_CONTROLLER_PROMPT",
"API_CONTROLLER_TOOL_NAME",
"API_CONTROLLER_TOOL_DESCRIPTION", "API_CONTROLLER_TOOL_DESCRIPTION",
"API_CONTROLLER_TOOL_NAME",
"API_ORCHESTRATOR_PROMPT", "API_ORCHESTRATOR_PROMPT",
"REQUESTS_GET_TOOL_DESCRIPTION", "API_PLANNER_PROMPT",
"API_PLANNER_TOOL_DESCRIPTION",
"API_PLANNER_TOOL_NAME",
"PARSING_DELETE_PROMPT",
"PARSING_GET_PROMPT", "PARSING_GET_PROMPT",
"REQUESTS_POST_TOOL_DESCRIPTION",
"PARSING_POST_PROMPT",
"REQUESTS_PATCH_TOOL_DESCRIPTION",
"PARSING_PATCH_PROMPT", "PARSING_PATCH_PROMPT",
"REQUESTS_PUT_TOOL_DESCRIPTION", "PARSING_POST_PROMPT",
"PARSING_PUT_PROMPT", "PARSING_PUT_PROMPT",
"REQUESTS_DELETE_TOOL_DESCRIPTION", "REQUESTS_DELETE_TOOL_DESCRIPTION",
"PARSING_DELETE_PROMPT", "REQUESTS_GET_TOOL_DESCRIPTION",
"REQUESTS_PATCH_TOOL_DESCRIPTION",
"REQUESTS_POST_TOOL_DESCRIPTION",
"REQUESTS_PUT_TOOL_DESCRIPTION",
] ]

View File

@ -26,4 +26,4 @@ def __getattr__(name: str) -> Any:
return _import_attribute(name) return _import_attribute(name)
__all__ = ["OPENAPI_PREFIX", "OPENAPI_SUFFIX", "DESCRIPTION"] __all__ = ["DESCRIPTION", "OPENAPI_PREFIX", "OPENAPI_SUFFIX"]

View File

@ -25,6 +25,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"RequestsToolkit",
"OpenAPIToolkit", "OpenAPIToolkit",
"RequestsToolkit",
] ]

View File

@ -29,8 +29,8 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"POWERBI_PREFIX",
"POWERBI_SUFFIX",
"POWERBI_CHAT_PREFIX", "POWERBI_CHAT_PREFIX",
"POWERBI_CHAT_SUFFIX", "POWERBI_CHAT_SUFFIX",
"POWERBI_PREFIX",
"POWERBI_SUFFIX",
] ]

View File

@ -26,4 +26,4 @@ def __getattr__(name: str) -> Any:
return _import_attribute(name) return _import_attribute(name)
__all__ = ["SQL_PREFIX", "SQL_SUFFIX", "SQL_FUNCTIONS_SUFFIX"] __all__ = ["SQL_FUNCTIONS_SUFFIX", "SQL_PREFIX", "SQL_SUFFIX"]

View File

@ -16,10 +16,10 @@ from langchain.agents.format_scratchpad.tools import format_to_tool_messages
from langchain.agents.format_scratchpad.xml import format_xml from langchain.agents.format_scratchpad.xml import format_xml
__all__ = [ __all__ = [
"format_xml", "format_log_to_messages",
"format_log_to_str",
"format_to_openai_function_messages", "format_to_openai_function_messages",
"format_to_openai_functions", "format_to_openai_functions",
"format_to_tool_messages", "format_to_tool_messages",
"format_log_to_str", "format_xml",
"format_log_to_messages",
] ]

View File

@ -20,8 +20,9 @@ def _convert_agent_action_to_messages(
the original tool invocation the original tool invocation
""" """
if isinstance(agent_action, AgentActionMessageLog): if isinstance(agent_action, AgentActionMessageLog):
return list(agent_action.message_log) + [ return [
_create_function_message(agent_action, observation) *list(agent_action.message_log),
_create_function_message(agent_action, observation),
] ]
return [AIMessage(content=agent_action.log)] return [AIMessage(content=agent_action.log)]

View File

@ -54,8 +54,9 @@ def format_to_tool_messages(
messages = [] messages = []
for agent_action, observation in intermediate_steps: for agent_action, observation in intermediate_steps:
if isinstance(agent_action, ToolAgentAction): if isinstance(agent_action, ToolAgentAction):
new_messages = list(agent_action.message_log) + [ new_messages = [
_create_tool_message(agent_action, observation) *list(agent_action.message_log),
_create_tool_message(agent_action, observation),
] ]
messages.extend([new for new in new_messages if new not in messages]) messages.extend([new for new in new_messages if new not in messages])
else: else:

View File

@ -25,11 +25,11 @@ from langchain.agents.output_parsers.tools import ToolsAgentOutputParser
from langchain.agents.output_parsers.xml import XMLAgentOutputParser from langchain.agents.output_parsers.xml import XMLAgentOutputParser
__all__ = [ __all__ = [
"JSONAgentOutputParser",
"OpenAIFunctionsAgentOutputParser",
"ReActJsonSingleInputOutputParser",
"ReActSingleInputOutputParser", "ReActSingleInputOutputParser",
"SelfAskOutputParser", "SelfAskOutputParser",
"ToolsAgentOutputParser", "ToolsAgentOutputParser",
"ReActJsonSingleInputOutputParser",
"OpenAIFunctionsAgentOutputParser",
"XMLAgentOutputParser", "XMLAgentOutputParser",
"JSONAgentOutputParser",
] ]

View File

@ -189,7 +189,7 @@ def create_self_ask_with_search_agent(
if len(tools) != 1: if len(tools) != 1:
msg = "This agent expects exactly one tool" msg = "This agent expects exactly one tool"
raise ValueError(msg) raise ValueError(msg)
tool = list(tools)[0] tool = next(iter(tools))
if tool.name != "Intermediate Answer": if tool.name != "Intermediate Answer":
msg = "This agent expects the tool to be named `Intermediate Answer`" msg = "This agent expects the tool to be named `Intermediate Answer`"
raise ValueError(msg) raise ValueError(msg)

View File

@ -53,20 +53,20 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"FullLLMCache",
"SQLAlchemyCache",
"SQLiteCache",
"UpstashRedisCache",
"RedisCache",
"RedisSemanticCache",
"GPTCache",
"MomentoCache",
"InMemoryCache",
"CassandraCache",
"CassandraSemanticCache",
"FullMd5LLMCache",
"SQLAlchemyMd5Cache",
"AstraDBCache", "AstraDBCache",
"AstraDBSemanticCache", "AstraDBSemanticCache",
"AzureCosmosDBSemanticCache", "AzureCosmosDBSemanticCache",
"CassandraCache",
"CassandraSemanticCache",
"FullLLMCache",
"FullMd5LLMCache",
"GPTCache",
"InMemoryCache",
"MomentoCache",
"RedisCache",
"RedisSemanticCache",
"SQLAlchemyCache",
"SQLAlchemyMd5Cache",
"SQLiteCache",
"UpstashRedisCache",
] ]

View File

@ -107,33 +107,33 @@ __all__ = [
"AimCallbackHandler", "AimCallbackHandler",
"ArgillaCallbackHandler", "ArgillaCallbackHandler",
"ArizeCallbackHandler", "ArizeCallbackHandler",
"PromptLayerCallbackHandler",
"ArthurCallbackHandler", "ArthurCallbackHandler",
"AsyncIteratorCallbackHandler",
"ClearMLCallbackHandler", "ClearMLCallbackHandler",
"CometCallbackHandler", "CometCallbackHandler",
"ContextCallbackHandler", "ContextCallbackHandler",
"FileCallbackHandler", "FileCallbackHandler",
"FinalStreamingStdOutCallbackHandler",
"FlyteCallbackHandler",
"HumanApprovalCallbackHandler", "HumanApprovalCallbackHandler",
"InfinoCallbackHandler", "InfinoCallbackHandler",
"MlflowCallbackHandler",
"LLMonitorCallbackHandler",
"OpenAICallbackHandler",
"StdOutCallbackHandler",
"AsyncIteratorCallbackHandler",
"StreamingStdOutCallbackHandler",
"FinalStreamingStdOutCallbackHandler",
"LLMThoughtLabeler", "LLMThoughtLabeler",
"LLMonitorCallbackHandler",
"LabelStudioCallbackHandler",
"LangChainTracer", "LangChainTracer",
"MlflowCallbackHandler",
"OpenAICallbackHandler",
"PromptLayerCallbackHandler",
"SageMakerCallbackHandler",
"StdOutCallbackHandler",
"StreamingStdOutCallbackHandler",
"StreamlitCallbackHandler", "StreamlitCallbackHandler",
"TrubricsCallbackHandler",
"WandbCallbackHandler", "WandbCallbackHandler",
"WhyLabsCallbackHandler", "WhyLabsCallbackHandler",
"collect_runs",
"get_openai_callback", "get_openai_callback",
"tracing_enabled", "tracing_enabled",
"tracing_v2_enabled", "tracing_v2_enabled",
"collect_runs",
"wandb_tracing_enabled", "wandb_tracing_enabled",
"FlyteCallbackHandler",
"SageMakerCallbackHandler",
"LabelStudioCallbackHandler",
"TrubricsCallbackHandler",
] ]

View File

@ -27,7 +27,7 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"import_aim",
"BaseMetadataCallbackHandler",
"AimCallbackHandler", "AimCallbackHandler",
"BaseMetadataCallbackHandler",
"import_aim",
] ]

View File

@ -16,14 +16,14 @@ from langchain_core.callbacks import (
) )
__all__ = [ __all__ = [
"RetrieverManagerMixin",
"LLMManagerMixin",
"ChainManagerMixin",
"ToolManagerMixin",
"CallbackManagerMixin",
"RunManagerMixin",
"BaseCallbackHandler",
"AsyncCallbackHandler", "AsyncCallbackHandler",
"BaseCallbackHandler",
"BaseCallbackManager", "BaseCallbackManager",
"CallbackManagerMixin",
"Callbacks", "Callbacks",
"ChainManagerMixin",
"LLMManagerMixin",
"RetrieverManagerMixin",
"RunManagerMixin",
"ToolManagerMixin",
] ]

View File

@ -27,7 +27,7 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"HumanRejectedException",
"HumanApprovalCallbackHandler",
"AsyncHumanApprovalCallbackHandler", "AsyncHumanApprovalCallbackHandler",
"HumanApprovalCallbackHandler",
"HumanRejectedException",
] ]

View File

@ -27,7 +27,7 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"LabelStudioCallbackHandler",
"LabelStudioMode", "LabelStudioMode",
"get_default_label_configs", "get_default_label_configs",
"LabelStudioCallbackHandler",
] ]

View File

@ -58,7 +58,7 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"ahandle_event", "AsyncCallbackManager",
"AsyncCallbackManagerForChainGroup", "AsyncCallbackManagerForChainGroup",
"AsyncCallbackManagerForChainRun", "AsyncCallbackManagerForChainRun",
"AsyncCallbackManagerForLLMRun", "AsyncCallbackManagerForLLMRun",
@ -66,7 +66,6 @@ __all__ = [
"AsyncCallbackManagerForToolRun", "AsyncCallbackManagerForToolRun",
"AsyncParentRunManager", "AsyncParentRunManager",
"AsyncRunManager", "AsyncRunManager",
"atrace_as_chain_group",
"BaseRunManager", "BaseRunManager",
"CallbackManager", "CallbackManager",
"CallbackManagerForChainGroup", "CallbackManagerForChainGroup",
@ -75,13 +74,14 @@ __all__ = [
"CallbackManagerForRetrieverRun", "CallbackManagerForRetrieverRun",
"CallbackManagerForToolRun", "CallbackManagerForToolRun",
"Callbacks", "Callbacks",
"AsyncCallbackManager", "ParentRunManager",
"RunManager",
"ahandle_event",
"atrace_as_chain_group",
"collect_runs", "collect_runs",
"env_var_is_set", "env_var_is_set",
"get_openai_callback", "get_openai_callback",
"handle_event", "handle_event",
"ParentRunManager",
"RunManager",
"trace_as_chain_group", "trace_as_chain_group",
"tracing_enabled", "tracing_enabled",
"tracing_v2_enabled", "tracing_v2_enabled",

View File

@ -31,8 +31,8 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"MlflowCallbackHandler",
"MlflowLogger",
"analyze_text", "analyze_text",
"construct_html_from_prompt_and_generation", "construct_html_from_prompt_and_generation",
"MlflowLogger",
"MlflowCallbackHandler",
] ]

View File

@ -27,7 +27,7 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"ChildType",
"ChildRecord", "ChildRecord",
"ChildType",
"MutableExpander", "MutableExpander",
] ]

View File

@ -41,9 +41,9 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"LLMThoughtState",
"ToolRecord",
"LLMThoughtLabeler",
"LLMThought", "LLMThought",
"LLMThoughtLabeler",
"LLMThoughtState",
"StreamlitCallbackHandler", "StreamlitCallbackHandler",
"ToolRecord",
] ]

View File

@ -31,8 +31,8 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"ConsoleCallbackHandler", "ConsoleCallbackHandler",
"FunctionCallbackHandler", "FunctionCallbackHandler",
"LoggingCallbackHandler",
"LangChainTracer", "LangChainTracer",
"LangChainTracerV1", "LangChainTracerV1",
"LoggingCallbackHandler",
"WandbTracer", "WandbTracer",
] ]

View File

@ -25,6 +25,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"import_comet_llm_api",
"CometTracer", "CometTracer",
"import_comet_llm_api",
] ]

View File

@ -5,4 +5,4 @@ from langchain_core.tracers.evaluation import (
wait_for_all_evaluators, wait_for_all_evaluators,
) )
__all__ = ["wait_for_all_evaluators", "EvaluatorCallbackHandler"] __all__ = ["EvaluatorCallbackHandler", "wait_for_all_evaluators"]

View File

@ -6,4 +6,4 @@ from langchain_core.tracers.log_stream import (
RunState, RunState,
) )
__all__ = ["LogEntry", "RunState", "RunLog", "RunLogPatch", "LogStreamCallbackHandler"] __all__ = ["LogEntry", "LogStreamCallbackHandler", "RunLog", "RunLogPatch", "RunState"]

View File

@ -3,4 +3,4 @@ from langchain_core.tracers.stdout import (
FunctionCallbackHandler, FunctionCallbackHandler,
) )
__all__ = ["FunctionCallbackHandler", "ConsoleCallbackHandler"] __all__ = ["ConsoleCallbackHandler", "FunctionCallbackHandler"]

View File

@ -37,12 +37,12 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"import_spacy", "BaseMetadataCallbackHandler",
"import_pandas",
"import_textstat",
"_flatten_dict", "_flatten_dict",
"flatten_dict", "flatten_dict",
"hash_string", "hash_string",
"import_pandas",
"import_spacy",
"import_textstat",
"load_json", "load_json",
"BaseMetadataCallbackHandler",
] ]

View File

@ -61,7 +61,7 @@ try:
message=( message=(
"This class is deprecated and will be removed in langchain 1.0. " "This class is deprecated and will be removed in langchain 1.0. "
"See API reference for replacement: " "See API reference for replacement: "
"https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html" # noqa: E501 "https://api.python.langchain.com/en/latest/chains/langchain.chains.api.base.APIChain.html"
), ),
removal="1.0", removal="1.0",
) )

View File

@ -26,4 +26,4 @@ def __getattr__(name: str) -> Any:
return _import_attribute(name) return _import_attribute(name)
__all__ = ["APIRequesterChain", "APIRequesterOutputParser", "REQUEST_TEMPLATE"] __all__ = ["REQUEST_TEMPLATE", "APIRequesterChain", "APIRequesterOutputParser"]

View File

@ -26,4 +26,4 @@ def __getattr__(name: str) -> Any:
return _import_attribute(name) return _import_attribute(name)
__all__ = ["APIResponderChain", "APIResponderOutputParser", "RESPONSE_TEMPLATE"] __all__ = ["RESPONSE_TEMPLATE", "APIResponderChain", "APIResponderOutputParser"]

View File

@ -521,7 +521,7 @@ class Chain(RunnableSerializable[dict[str, Any], dict[str, Any]], ABC):
# If there are multiple input keys, but some get set by memory so that # If there are multiple input keys, but some get set by memory so that
# only one is not set, we can still figure out which key it is. # only one is not set, we can still figure out which key it is.
_input_keys = _input_keys.difference(self.memory.memory_variables) _input_keys = _input_keys.difference(self.memory.memory_variables)
inputs = {list(_input_keys)[0]: inputs} inputs = {next(iter(_input_keys)): inputs}
if self.memory is not None: if self.memory is not None:
external_context = self.memory.load_memory_variables(inputs) external_context = self.memory.load_memory_variables(inputs)
inputs = dict(inputs, **external_context) inputs = dict(inputs, **external_context)
@ -545,7 +545,7 @@ class Chain(RunnableSerializable[dict[str, Any], dict[str, Any]], ABC):
# If there are multiple input keys, but some get set by memory so that # If there are multiple input keys, but some get set by memory so that
# only one is not set, we can still figure out which key it is. # only one is not set, we can still figure out which key it is.
_input_keys = _input_keys.difference(self.memory.memory_variables) _input_keys = _input_keys.difference(self.memory.memory_variables)
inputs = {list(_input_keys)[0]: inputs} inputs = {next(iter(_input_keys)): inputs}
if self.memory is not None: if self.memory is not None:
external_context = await self.memory.aload_memory_variables(inputs) external_context = await self.memory.aload_memory_variables(inputs)
inputs = dict(inputs, **external_context) inputs = dict(inputs, **external_context)

View File

@ -10,6 +10,6 @@ from langchain.chains.combine_documents.stuff import create_stuff_documents_chai
__all__ = [ __all__ = [
"acollapse_docs", "acollapse_docs",
"collapse_docs", "collapse_docs",
"split_list_of_docs",
"create_stuff_documents_chain", "create_stuff_documents_chain",
"split_list_of_docs",
] ]

View File

@ -163,7 +163,7 @@ class BaseCombineDocumentsChain(Chain, ABC):
since="0.2.7", since="0.2.7",
alternative=( alternative=(
"example in API reference with more detail: " "example in API reference with more detail: "
"https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.base.AnalyzeDocumentChain.html" # noqa: E501 "https://api.python.langchain.com/en/latest/chains/langchain.chains.combine_documents.base.AnalyzeDocumentChain.html"
), ),
removal="1.0", removal="1.0",
) )

View File

@ -133,7 +133,7 @@ class MapReduceDocumentsChain(BaseCombineDocumentsChain):
""" """
_output_keys = super().output_keys _output_keys = super().output_keys
if self.return_intermediate_steps: if self.return_intermediate_steps:
_output_keys = _output_keys + ["intermediate_steps"] _output_keys = [*_output_keys, "intermediate_steps"]
return _output_keys return _output_keys
model_config = ConfigDict( model_config = ConfigDict(
@ -161,8 +161,7 @@ class MapReduceDocumentsChain(BaseCombineDocumentsChain):
) )
values["reduce_documents_chain"] = reduce_chain values["reduce_documents_chain"] = reduce_chain
del values["combine_document_chain"] del values["combine_document_chain"]
if "collapse_document_chain" in values: values.pop("collapse_document_chain", None)
del values["collapse_document_chain"]
return values return values

View File

@ -24,7 +24,7 @@ from langchain.output_parsers.regex import RegexParser
message=( message=(
"This class is deprecated. Please see the migration guide here for " "This class is deprecated. Please see the migration guide here for "
"a recommended replacement: " "a recommended replacement: "
"https://python.langchain.com/docs/versions/migrating_chains/map_rerank_docs_chain/" # noqa: E501 "https://python.langchain.com/docs/versions/migrating_chains/map_rerank_docs_chain/"
), ),
) )
class MapRerankDocumentsChain(BaseCombineDocumentsChain): class MapRerankDocumentsChain(BaseCombineDocumentsChain):
@ -112,7 +112,7 @@ class MapRerankDocumentsChain(BaseCombineDocumentsChain):
""" """
_output_keys = super().output_keys _output_keys = super().output_keys
if self.return_intermediate_steps: if self.return_intermediate_steps:
_output_keys = _output_keys + ["intermediate_steps"] _output_keys = [*_output_keys, "intermediate_steps"]
if self.metadata_keys is not None: if self.metadata_keys is not None:
_output_keys += self.metadata_keys _output_keys += self.metadata_keys
return _output_keys return _output_keys

View File

@ -27,7 +27,7 @@ def _get_default_document_prompt() -> PromptTemplate:
message=( message=(
"This class is deprecated. Please see the migration guide here for " "This class is deprecated. Please see the migration guide here for "
"a recommended replacement: " "a recommended replacement: "
"https://python.langchain.com/docs/versions/migrating_chains/refine_docs_chain/" # noqa: E501 "https://python.langchain.com/docs/versions/migrating_chains/refine_docs_chain/"
), ),
) )
class RefineDocumentsChain(BaseCombineDocumentsChain): class RefineDocumentsChain(BaseCombineDocumentsChain):
@ -105,7 +105,7 @@ class RefineDocumentsChain(BaseCombineDocumentsChain):
""" """
_output_keys = super().output_keys _output_keys = super().output_keys
if self.return_intermediate_steps: if self.return_intermediate_steps:
_output_keys = _output_keys + ["intermediate_steps"] _output_keys = [*_output_keys, "intermediate_steps"]
return _output_keys return _output_keys
model_config = ConfigDict( model_config = ConfigDict(

View File

@ -102,7 +102,7 @@ def create_stuff_documents_chain(
message=( message=(
"This class is deprecated. Use the `create_stuff_documents_chain` constructor " "This class is deprecated. Use the `create_stuff_documents_chain` constructor "
"instead. See migration guide here: " "instead. See migration guide here: "
"https://python.langchain.com/docs/versions/migrating_chains/stuff_docs_chain/" # noqa: E501 "https://python.langchain.com/docs/versions/migrating_chains/stuff_docs_chain/"
), ),
) )
class StuffDocumentsChain(BaseCombineDocumentsChain): class StuffDocumentsChain(BaseCombineDocumentsChain):

View File

@ -19,7 +19,7 @@ from langchain.chains.llm import LLMChain
message=( message=(
"This class is deprecated and will be removed in langchain 1.0. " "This class is deprecated and will be removed in langchain 1.0. "
"See API reference for replacement: " "See API reference for replacement: "
"https://api.python.langchain.com/en/latest/chains/langchain.chains.constitutional_ai.base.ConstitutionalChain.html" # noqa: E501 "https://api.python.langchain.com/en/latest/chains/langchain.chains.constitutional_ai.base.ConstitutionalChain.html"
), ),
removal="1.0", removal="1.0",
) )

View File

@ -132,7 +132,7 @@ class ConversationChain(LLMChain):
) )
raise ValueError(msg) raise ValueError(msg)
prompt_variables = self.prompt.input_variables prompt_variables = self.prompt.input_variables
expected_keys = memory_keys + [input_key] expected_keys = [*memory_keys, input_key]
if set(expected_keys) != set(prompt_variables): if set(expected_keys) != set(prompt_variables):
msg = ( msg = (
"Got unexpected prompt input variables. The prompt expects " "Got unexpected prompt input variables. The prompt expects "

View File

@ -34,12 +34,12 @@ def __getattr__(name: str) -> Any:
# This is only for backwards compatibility. # This is only for backwards compatibility.
__all__ = [ __all__ = [
"ConversationSummaryBufferMemory", "CombinedMemory",
"ConversationSummaryMemory", "ConversationBufferMemory",
"ConversationKGMemory",
"ConversationBufferWindowMemory", "ConversationBufferWindowMemory",
"ConversationEntityMemory", "ConversationEntityMemory",
"ConversationBufferMemory", "ConversationKGMemory",
"CombinedMemory",
"ConversationStringBufferMemory", "ConversationStringBufferMemory",
"ConversationSummaryBufferMemory",
"ConversationSummaryMemory",
] ]

View File

@ -121,9 +121,9 @@ class BaseConversationalRetrievalChain(Chain):
""" """
_output_keys = [self.output_key] _output_keys = [self.output_key]
if self.return_source_documents: if self.return_source_documents:
_output_keys = _output_keys + ["source_documents"] _output_keys = [*_output_keys, "source_documents"]
if self.return_generated_question: if self.return_generated_question:
_output_keys = _output_keys + ["generated_question"] _output_keys = [*_output_keys, "generated_question"]
return _output_keys return _output_keys
@abstractmethod @abstractmethod

View File

@ -36,9 +36,9 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"convert_to_ernie_function", "convert_to_ernie_function",
"create_structured_output_chain",
"create_ernie_fn_chain", "create_ernie_fn_chain",
"create_structured_output_runnable",
"create_ernie_fn_runnable", "create_ernie_fn_runnable",
"create_structured_output_chain",
"create_structured_output_runnable",
"get_ernie_output_parser", "get_ernie_output_parser",
] ]

View File

@ -31,9 +31,9 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"GraphCypherQAChain", "CYPHER_GENERATION_PROMPT",
"INTERMEDIATE_STEPS_KEY", "INTERMEDIATE_STEPS_KEY",
"GraphCypherQAChain",
"construct_schema", "construct_schema",
"extract_cypher", "extract_cypher",
"CYPHER_GENERATION_PROMPT",
] ]

View File

@ -26,4 +26,4 @@ def __getattr__(name: str) -> Any:
return _import_attribute(name) return _import_attribute(name)
__all__ = ["FalkorDBQAChain", "INTERMEDIATE_STEPS_KEY", "extract_cypher"] __all__ = ["INTERMEDIATE_STEPS_KEY", "FalkorDBQAChain", "extract_cypher"]

View File

@ -30,7 +30,7 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"GRAPHDB_SPARQL_FIX_TEMPLATE", "GRAPHDB_SPARQL_FIX_TEMPLATE",
"GremlinQAChain",
"INTERMEDIATE_STEPS_KEY", "INTERMEDIATE_STEPS_KEY",
"GremlinQAChain",
"extract_gremlin", "extract_gremlin",
] ]

View File

@ -30,7 +30,7 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"INTERMEDIATE_STEPS_KEY", "INTERMEDIATE_STEPS_KEY",
"NeptuneSparqlQAChain",
"SPARQL_GENERATION_TEMPLATE", "SPARQL_GENERATION_TEMPLATE",
"NeptuneSparqlQAChain",
"extract_sparql", "extract_sparql",
] ]

View File

@ -74,7 +74,9 @@ __all__ = [
"AQL_FIX_TEMPLATE", "AQL_FIX_TEMPLATE",
"AQL_GENERATION_TEMPLATE", "AQL_GENERATION_TEMPLATE",
"AQL_QA_TEMPLATE", "AQL_QA_TEMPLATE",
"CYPHER_GENERATION_PROMPT",
"CYPHER_GENERATION_TEMPLATE", "CYPHER_GENERATION_TEMPLATE",
"CYPHER_QA_PROMPT",
"CYPHER_QA_TEMPLATE", "CYPHER_QA_TEMPLATE",
"GRAPHDB_QA_TEMPLATE", "GRAPHDB_QA_TEMPLATE",
"GRAPHDB_SPARQL_FIX_TEMPLATE", "GRAPHDB_SPARQL_FIX_TEMPLATE",
@ -91,6 +93,4 @@ __all__ = [
"SPARQL_GENERATION_UPDATE_TEMPLATE", "SPARQL_GENERATION_UPDATE_TEMPLATE",
"SPARQL_INTENT_TEMPLATE", "SPARQL_INTENT_TEMPLATE",
"SPARQL_QA_TEMPLATE", "SPARQL_QA_TEMPLATE",
"CYPHER_QA_PROMPT",
"CYPHER_GENERATION_PROMPT",
] ]

View File

@ -26,7 +26,7 @@ from langchain.chains.llm_math.prompt import PROMPT
message=( message=(
"This class is deprecated and will be removed in langchain 1.0. " "This class is deprecated and will be removed in langchain 1.0. "
"See API reference for replacement: " "See API reference for replacement: "
"https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_math.base.LLMMathChain.html" # noqa: E501 "https://api.python.langchain.com/en/latest/chains/langchain.chains.llm_math.base.LLMMathChain.html"
), ),
removal="1.0", removal="1.0",
) )

View File

@ -30,7 +30,7 @@ from langchain.chains.llm import LLMChain
removal="1.0", removal="1.0",
message=( message=(
"Refer to migration guide here for a recommended implementation using " "Refer to migration guide here for a recommended implementation using "
"LangGraph: https://python.langchain.com/docs/versions/migrating_chains/map_reduce_chain/" # noqa: E501 "LangGraph: https://python.langchain.com/docs/versions/migrating_chains/map_reduce_chain/"
". See also LangGraph guides for map-reduce: " ". See also LangGraph guides for map-reduce: "
"https://langchain-ai.github.io/langgraph/how-tos/map-reduce/." "https://langchain-ai.github.io/langgraph/how-tos/map-reduce/."
), ),

View File

@ -28,17 +28,17 @@ from langchain.chains.structured_output.base import (
__all__ = [ __all__ = [
"convert_to_openai_function", "convert_to_openai_function",
"create_tagging_chain",
"create_tagging_chain_pydantic",
"create_extraction_chain_pydantic",
"create_extraction_chain",
"create_citation_fuzzy_match_chain", "create_citation_fuzzy_match_chain",
"create_citation_fuzzy_match_runnable", "create_citation_fuzzy_match_runnable",
"create_qa_with_structure_chain", "create_extraction_chain",
"create_qa_with_sources_chain", "create_extraction_chain_pydantic",
"create_structured_output_chain",
"create_openai_fn_chain", "create_openai_fn_chain",
"create_structured_output_runnable", # backwards compatibility
"create_openai_fn_runnable", # backwards compatibility "create_openai_fn_runnable", # backwards compatibility
"create_qa_with_sources_chain",
"create_qa_with_structure_chain",
"create_structured_output_chain",
"create_structured_output_runnable", # backwards compatibility
"create_tagging_chain",
"create_tagging_chain_pydantic",
"get_openai_output_parser", # backwards compatibility "get_openai_output_parser", # backwards compatibility
] ]

View File

@ -31,13 +31,13 @@ from langchain.chains.structured_output.base import (
) )
__all__ = [ __all__ = [
"get_openai_output_parser",
"create_openai_fn_runnable",
"create_structured_output_runnable", # deprecated
"create_openai_fn_chain", # deprecated
"create_structured_output_chain", # deprecated
"PYTHON_TO_JSON_TYPES", # backwards compatibility "PYTHON_TO_JSON_TYPES", # backwards compatibility
"convert_to_openai_function", # backwards compatibility "convert_to_openai_function", # backwards compatibility
"create_openai_fn_chain", # deprecated
"create_openai_fn_runnable",
"create_structured_output_chain", # deprecated
"create_structured_output_runnable", # deprecated
"get_openai_output_parser",
] ]

View File

@ -69,7 +69,7 @@ def _openapi_params_to_json_schema(params: list[Parameter], spec: OpenAPISpec) -
if p.param_schema: if p.param_schema:
schema = spec.get_schema(p.param_schema) schema = spec.get_schema(p.param_schema)
else: else:
media_type_schema = list(p.content.values())[0].media_type_schema media_type_schema = next(iter(p.content.values())).media_type_schema
schema = spec.get_schema(media_type_schema) schema = spec.get_schema(media_type_schema)
if p.description and not schema.description: if p.description and not schema.description:
schema.description = p.description schema.description = p.description
@ -140,7 +140,7 @@ def openapi_spec_to_openai_fn(
schema.json(exclude_none=True) schema.json(exclude_none=True)
) )
if len(media_types) == 1: if len(media_types) == 1:
media_type, schema_dict = list(media_types.items())[0] media_type, schema_dict = next(iter(media_types.items()))
key = "json" if media_type == "application/json" else "data" key = "json" if media_type == "application/json" else "data"
request_args[key] = schema_dict request_args[key] = schema_dict
elif len(media_types) > 1: elif len(media_types) > 1:
@ -242,7 +242,7 @@ class SimpleRequestChain(Chain):
message=( message=(
"This function is deprecated and will be removed in langchain 1.0. " "This function is deprecated and will be removed in langchain 1.0. "
"See API reference for replacement: " "See API reference for replacement: "
"https://api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.openapi.get_openapi_chain.html" # noqa: E501 "https://api.python.langchain.com/en/latest/chains/langchain.chains.openai_functions.openapi.get_openapi_chain.html"
), ),
removal="1.0", removal="1.0",
) )

View File

@ -32,7 +32,7 @@ class AnswerWithSources(BaseModel):
message=( message=(
"This function is deprecated. Refer to this guide on retrieval and question " "This function is deprecated. Refer to this guide on retrieval and question "
"answering with structured responses: " "answering with structured responses: "
"https://python.langchain.com/docs/how_to/qa_sources/#structure-sources-in-model-response" # noqa: E501 "https://python.langchain.com/docs/how_to/qa_sources/#structure-sources-in-model-response"
), ),
) )
def create_qa_with_structure_chain( def create_qa_with_structure_chain(
@ -115,7 +115,7 @@ def create_qa_with_structure_chain(
message=( message=(
"This function is deprecated. Refer to this guide on retrieval and question " "This function is deprecated. Refer to this guide on retrieval and question "
"answering with sources: " "answering with sources: "
"https://python.langchain.com/docs/how_to/qa_sources/#structure-sources-in-model-response" # noqa: E501 "https://python.langchain.com/docs/how_to/qa_sources/#structure-sources-in-model-response"
), ),
) )
def create_qa_with_sources_chain( def create_qa_with_sources_chain(

View File

@ -19,7 +19,7 @@ from langchain.chains.qa_generation.prompt import PROMPT_SELECTOR
since="0.2.7", since="0.2.7",
alternative=( alternative=(
"example in API reference with more detail: " "example in API reference with more detail: "
"https://api.python.langchain.com/en/latest/chains/langchain.chains.qa_generation.base.QAGenerationChain.html" # noqa: E501 "https://api.python.langchain.com/en/latest/chains/langchain.chains.qa_generation.base.QAGenerationChain.html"
), ),
removal="1.0", removal="1.0",
) )

View File

@ -118,7 +118,7 @@ class BaseQAWithSourcesChain(Chain, ABC):
""" """
_output_keys = [self.answer_key, self.sources_answer_key] _output_keys = [self.answer_key, self.sources_answer_key]
if self.return_source_documents: if self.return_source_documents:
_output_keys = _output_keys + ["source_documents"] _output_keys = [*_output_keys, "source_documents"]
return _output_keys return _output_keys
@model_validator(mode="before") @model_validator(mode="before")

View File

@ -167,10 +167,10 @@ def _load_refine_chain(
"https://python.langchain.com/docs/how_to/qa_sources/" "https://python.langchain.com/docs/how_to/qa_sources/"
"\nSee also the following migration guides for replacements " "\nSee also the following migration guides for replacements "
"based on `chain_type`:\n" "based on `chain_type`:\n"
"stuff: https://python.langchain.com/docs/versions/migrating_chains/stuff_docs_chain\n" # noqa: E501 "stuff: https://python.langchain.com/docs/versions/migrating_chains/stuff_docs_chain\n"
"map_reduce: https://python.langchain.com/docs/versions/migrating_chains/map_reduce_chain\n" # noqa: E501 "map_reduce: https://python.langchain.com/docs/versions/migrating_chains/map_reduce_chain\n"
"refine: https://python.langchain.com/docs/versions/migrating_chains/refine_chain\n" # noqa: E501 "refine: https://python.langchain.com/docs/versions/migrating_chains/refine_chain\n"
"map_rerank: https://python.langchain.com/docs/versions/migrating_chains/map_rerank_docs_chain\n" # noqa: E501 "map_rerank: https://python.langchain.com/docs/versions/migrating_chains/map_rerank_docs_chain\n"
), ),
) )
def load_qa_with_sources_chain( def load_qa_with_sources_chain(

View File

@ -12,12 +12,12 @@ from langchain_core.structured_query import (
) )
__all__ = [ __all__ = [
"Visitor",
"Expr",
"Operator",
"Comparator", "Comparator",
"FilterDirective",
"Comparison", "Comparison",
"Expr",
"FilterDirective",
"Operation", "Operation",
"Operator",
"StructuredQuery", "StructuredQuery",
"Visitor",
] ]

View File

@ -229,10 +229,10 @@ def _load_refine_chain(
message=( message=(
"This class is deprecated. See the following migration guides for replacements " "This class is deprecated. See the following migration guides for replacements "
"based on `chain_type`:\n" "based on `chain_type`:\n"
"stuff: https://python.langchain.com/docs/versions/migrating_chains/stuff_docs_chain\n" # noqa: E501 "stuff: https://python.langchain.com/docs/versions/migrating_chains/stuff_docs_chain\n"
"map_reduce: https://python.langchain.com/docs/versions/migrating_chains/map_reduce_chain\n" # noqa: E501 "map_reduce: https://python.langchain.com/docs/versions/migrating_chains/map_reduce_chain\n"
"refine: https://python.langchain.com/docs/versions/migrating_chains/refine_chain\n" # noqa: E501 "refine: https://python.langchain.com/docs/versions/migrating_chains/refine_chain\n"
"map_rerank: https://python.langchain.com/docs/versions/migrating_chains/map_rerank_docs_chain\n" # noqa: E501 "map_rerank: https://python.langchain.com/docs/versions/migrating_chains/map_rerank_docs_chain\n"
"\nSee also guides on retrieval and question-answering here: " "\nSee also guides on retrieval and question-answering here: "
"https://python.langchain.com/docs/how_to/#qa-with-rag" "https://python.langchain.com/docs/how_to/#qa-with-rag"
), ),

View File

@ -69,7 +69,7 @@ class BaseRetrievalQA(Chain):
""" """
_output_keys = [self.output_key] _output_keys = [self.output_key]
if self.return_source_documents: if self.return_source_documents:
_output_keys = _output_keys + ["source_documents"] _output_keys = [*_output_keys, "source_documents"]
return _output_keys return _output_keys
@classmethod @classmethod

View File

@ -4,9 +4,9 @@ from langchain.chains.router.multi_prompt import MultiPromptChain
from langchain.chains.router.multi_retrieval_qa import MultiRetrievalQAChain from langchain.chains.router.multi_retrieval_qa import MultiRetrievalQAChain
__all__ = [ __all__ = [
"RouterChain", "LLMRouterChain",
"MultiRouteChain",
"MultiPromptChain", "MultiPromptChain",
"MultiRetrievalQAChain", "MultiRetrievalQAChain",
"LLMRouterChain", "MultiRouteChain",
"RouterChain",
] ]

View File

@ -27,7 +27,7 @@ from langchain.chains.router.base import RouterChain
message=( message=(
"Use RunnableLambda to select from multiple prompt templates. See example " "Use RunnableLambda to select from multiple prompt templates. See example "
"in API reference: " "in API reference: "
"https://api.python.langchain.com/en/latest/chains/langchain.chains.router.llm_router.LLMRouterChain.html" # noqa: E501 "https://api.python.langchain.com/en/latest/chains/langchain.chains.router.llm_router.LLMRouterChain.html"
), ),
) )
class LLMRouterChain(RouterChain): class LLMRouterChain(RouterChain):

View File

@ -21,7 +21,7 @@ from langchain.chains.router.multi_prompt_prompt import MULTI_PROMPT_ROUTER_TEMP
removal="1.0", removal="1.0",
message=( message=(
"Please see migration guide here for recommended implementation: " "Please see migration guide here for recommended implementation: "
"https://python.langchain.com/docs/versions/migrating_chains/multi_prompt_chain/" # noqa: E501 "https://python.langchain.com/docs/versions/migrating_chains/multi_prompt_chain/"
), ),
) )
class MultiPromptChain(MultiRouteChain): class MultiPromptChain(MultiRouteChain):

View File

@ -3,4 +3,4 @@ from langchain.chains.structured_output.base import (
create_structured_output_runnable, create_structured_output_runnable,
) )
__all__ = ["create_structured_output_runnable", "create_openai_fn_runnable"] __all__ = ["create_openai_fn_runnable", "create_structured_output_runnable"]

View File

@ -29,4 +29,4 @@ def __getattr__(name: str) -> Any:
return import_lookup(name) return import_lookup(name)
__all__ = ["SingleFileFacebookMessengerChatLoader", "FolderFacebookMessengerChatLoader"] __all__ = ["FolderFacebookMessengerChatLoader", "SingleFileFacebookMessengerChatLoader"]

View File

@ -25,6 +25,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"LangSmithRunChatLoader",
"LangSmithDatasetChatLoader", "LangSmithDatasetChatLoader",
"LangSmithRunChatLoader",
] ]

View File

@ -29,8 +29,8 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"merge_chat_runs_in_session",
"merge_chat_runs",
"map_ai_messages_in_session",
"map_ai_messages", "map_ai_messages",
"map_ai_messages_in_session",
"merge_chat_runs",
"merge_chat_runs_in_session",
] ]

View File

@ -43,35 +43,35 @@ def __getattr__(name: str) -> None:
__all__ = [ __all__ = [
"init_chat_model",
"ChatOpenAI",
"BedrockChat",
"AzureChatOpenAI", "AzureChatOpenAI",
"FakeListChatModel", "BedrockChat",
"PromptLayerChatOpenAI", "ChatAnthropic",
"ChatAnyscale",
"ChatBaichuan",
"ChatCohere",
"ChatDatabricks", "ChatDatabricks",
"ChatEverlyAI", "ChatEverlyAI",
"ChatAnthropic", "ChatFireworks",
"ChatCohere",
"ChatGooglePalm", "ChatGooglePalm",
"ChatMlflow", "ChatHunyuan",
"ChatMLflowAIGateway",
"ChatOllama",
"ChatVertexAI",
"JinaChat",
"HumanInputChatModel",
"MiniMaxChat",
"ChatAnyscale",
"ChatLiteLLM",
"ErnieBotChat",
"ChatJavelinAIGateway", "ChatJavelinAIGateway",
"ChatKonko", "ChatKonko",
"PaiEasChatEndpoint", "ChatLiteLLM",
"QianfanChatEndpoint", "ChatMLflowAIGateway",
"ChatFireworks", "ChatMlflow",
"ChatOllama",
"ChatOpenAI",
"ChatVertexAI",
"ChatYandexGPT", "ChatYandexGPT",
"ChatBaichuan", "ErnieBotChat",
"ChatHunyuan", "FakeListChatModel",
"GigaChat", "GigaChat",
"HumanInputChatModel",
"JinaChat",
"MiniMaxChat",
"PaiEasChatEndpoint",
"PromptLayerChatOpenAI",
"QianfanChatEndpoint",
"VolcEngineMaasChat", "VolcEngineMaasChat",
"init_chat_model",
] ]

View File

@ -25,6 +25,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"convert_messages_to_prompt_anthropic",
"ChatAnthropic", "ChatAnthropic",
"convert_messages_to_prompt_anthropic",
] ]

View File

@ -25,6 +25,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"LlamaContentFormatter",
"AzureMLChatOnlineEndpoint", "AzureMLChatOnlineEndpoint",
"LlamaContentFormatter",
] ]

View File

@ -31,12 +31,12 @@ from pydantic import BaseModel
from typing_extensions import TypeAlias, override from typing_extensions import TypeAlias, override
__all__ = [ __all__ = [
"init_chat_model",
# For backwards compatibility # For backwards compatibility
"BaseChatModel", "BaseChatModel",
"SimpleChatModel", "SimpleChatModel",
"generate_from_stream",
"agenerate_from_stream", "agenerate_from_stream",
"generate_from_stream",
"init_chat_model",
] ]

View File

@ -22,6 +22,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"ChatPromptAdapter",
"BedrockChat", "BedrockChat",
"ChatPromptAdapter",
] ]

View File

@ -25,6 +25,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"FakeMessagesListChatModel",
"FakeListChatModel", "FakeListChatModel",
"FakeMessagesListChatModel",
] ]

View File

@ -25,6 +25,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"convert_dict_to_message",
"VolcEngineMaasChat", "VolcEngineMaasChat",
"convert_dict_to_message",
] ]

View File

@ -22,6 +22,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"Docstore",
"AddableMixin", "AddableMixin",
"Docstore",
] ]

View File

@ -380,15 +380,13 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"AcreomLoader",
"AsyncHtmlLoader",
"AsyncChromiumLoader",
"AZLyricsLoader", "AZLyricsLoader",
"AcreomLoader", "AcreomLoader",
"AcreomLoader",
"AirbyteCDKLoader", "AirbyteCDKLoader",
"AirbyteGongLoader", "AirbyteGongLoader",
"AirbyteJSONLoader",
"AirbyteHubspotLoader", "AirbyteHubspotLoader",
"AirbyteJSONLoader",
"AirbyteSalesforceLoader", "AirbyteSalesforceLoader",
"AirbyteShopifyLoader", "AirbyteShopifyLoader",
"AirbyteStripeLoader", "AirbyteStripeLoader",
@ -400,6 +398,8 @@ __all__ = [
"ArcGISLoader", "ArcGISLoader",
"ArxivLoader", "ArxivLoader",
"AssemblyAIAudioTranscriptLoader", "AssemblyAIAudioTranscriptLoader",
"AsyncChromiumLoader",
"AsyncHtmlLoader",
"AsyncHtmlLoader", "AsyncHtmlLoader",
"AzureAIDataLoader", "AzureAIDataLoader",
"AzureBlobStorageContainerLoader", "AzureBlobStorageContainerLoader",
@ -441,14 +441,14 @@ __all__ = [
"GCSDirectoryLoader", "GCSDirectoryLoader",
"GCSFileLoader", "GCSFileLoader",
"GeoDataFrameLoader", "GeoDataFrameLoader",
"GithubFileLoader",
"GitHubIssuesLoader", "GitHubIssuesLoader",
"GitLoader", "GitLoader",
"GitbookLoader", "GitbookLoader",
"GithubFileLoader",
"GoogleApiClient", "GoogleApiClient",
"GoogleApiYoutubeLoader", "GoogleApiYoutubeLoader",
"GoogleSpeechToTextLoader",
"GoogleDriveLoader", "GoogleDriveLoader",
"GoogleSpeechToTextLoader",
"GutenbergLoader", "GutenbergLoader",
"HNLoader", "HNLoader",
"HuggingFaceDatasetLoader", "HuggingFaceDatasetLoader",
@ -458,8 +458,8 @@ __all__ = [
"IuguLoader", "IuguLoader",
"JSONLoader", "JSONLoader",
"JoplinLoader", "JoplinLoader",
"LarkSuiteDocLoader",
"LakeFSLoader", "LakeFSLoader",
"LarkSuiteDocLoader",
"MHTMLLoader", "MHTMLLoader",
"MWDumpLoader", "MWDumpLoader",
"MastodonTootsLoader", "MastodonTootsLoader",
@ -483,13 +483,13 @@ __all__ = [
"PDFMinerLoader", "PDFMinerLoader",
"PDFMinerPDFasHTMLLoader", "PDFMinerPDFasHTMLLoader",
"PDFPlumberLoader", "PDFPlumberLoader",
"PagedPDFSplitter",
"PlaywrightURLLoader", "PlaywrightURLLoader",
"PolarsDataFrameLoader", "PolarsDataFrameLoader",
"PsychicLoader", "PsychicLoader",
"PubMedLoader", "PubMedLoader",
"PyMuPDFLoader", "PyMuPDFLoader",
"PyPDFDirectoryLoader", "PyPDFDirectoryLoader",
"PagedPDFSplitter",
"PyPDFLoader", "PyPDFLoader",
"PyPDFium2Loader", "PyPDFium2Loader",
"PySparkDataFrameLoader", "PySparkDataFrameLoader",
@ -513,9 +513,9 @@ __all__ = [
"TelegramChatApiLoader", "TelegramChatApiLoader",
"TelegramChatFileLoader", "TelegramChatFileLoader",
"TelegramChatLoader", "TelegramChatLoader",
"TensorflowDatasetLoader",
"TencentCOSDirectoryLoader", "TencentCOSDirectoryLoader",
"TencentCOSFileLoader", "TencentCOSFileLoader",
"TensorflowDatasetLoader",
"TextLoader", "TextLoader",
"ToMarkdownLoader", "ToMarkdownLoader",
"TomlLoader", "TomlLoader",

View File

@ -38,11 +38,11 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"AirbyteCDKLoader", "AirbyteCDKLoader",
"AirbyteGongLoader",
"AirbyteHubspotLoader", "AirbyteHubspotLoader",
"AirbyteSalesforceLoader",
"AirbyteShopifyLoader",
"AirbyteStripeLoader", "AirbyteStripeLoader",
"AirbyteTypeformLoader", "AirbyteTypeformLoader",
"AirbyteZendeskSupportLoader", "AirbyteZendeskSupportLoader",
"AirbyteShopifyLoader",
"AirbyteSalesforceLoader",
"AirbyteGongLoader",
] ]

View File

@ -23,6 +23,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"TranscriptFormat",
"AssemblyAIAudioTranscriptLoader", "AssemblyAIAudioTranscriptLoader",
"TranscriptFormat",
] ]

View File

@ -1,3 +1,3 @@
from langchain_core.document_loaders import BaseBlobParser, BaseLoader from langchain_core.document_loaders import BaseBlobParser, BaseLoader
__all__ = ["BaseLoader", "BaseBlobParser"] __all__ = ["BaseBlobParser", "BaseLoader"]

View File

@ -29,8 +29,8 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"BlobLoader",
"Blob", "Blob",
"BlobLoader",
"FileSystemBlobLoader", "FileSystemBlobLoader",
"YoutubeAudioLoader", "YoutubeAudioLoader",
] ]

View File

@ -23,6 +23,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"BlockchainType",
"BlockchainDocumentLoader", "BlockchainDocumentLoader",
"BlockchainType",
] ]

View File

@ -23,6 +23,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"concatenate_rows",
"ChatGPTLoader", "ChatGPTLoader",
"concatenate_rows",
] ]

View File

@ -23,6 +23,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"ContentFormat",
"ConfluenceLoader", "ConfluenceLoader",
"ContentFormat",
] ]

View File

@ -25,6 +25,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"UnstructuredEmailLoader",
"OutlookMessageLoader", "OutlookMessageLoader",
"UnstructuredEmailLoader",
] ]

View File

@ -23,6 +23,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"concatenate_rows",
"FacebookChatLoader", "FacebookChatLoader",
"concatenate_rows",
] ]

View File

@ -27,7 +27,7 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"NotebookLoader",
"concatenate_cells", "concatenate_cells",
"remove_newlines", "remove_newlines",
"NotebookLoader",
] ]

View File

@ -53,6 +53,6 @@ __all__ = [
"PDFMinerParser", "PDFMinerParser",
"PDFPlumberParser", "PDFPlumberParser",
"PyMuPDFParser", "PyMuPDFParser",
"PyPDFium2Parser",
"PyPDFParser", "PyPDFParser",
"PyPDFium2Parser",
] ]

View File

@ -25,6 +25,6 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"DocAIParsingResults",
"DocAIParser", "DocAIParser",
"DocAIParsingResults",
] ]

View File

@ -39,12 +39,12 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"extract_from_images_with_rapidocr",
"PyPDFParser",
"PDFMinerParser",
"PyMuPDFParser",
"PyPDFium2Parser",
"PDFPlumberParser",
"AmazonTextractPDFParser", "AmazonTextractPDFParser",
"DocumentIntelligenceParser", "DocumentIntelligenceParser",
"PDFMinerParser",
"PDFPlumberParser",
"PyMuPDFParser",
"PyPDFParser",
"PyPDFium2Parser",
"extract_from_images_with_rapidocr",
] ]

View File

@ -49,17 +49,17 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"UnstructuredPDFLoader", "AmazonTextractPDFLoader",
"BasePDFLoader", "BasePDFLoader",
"DocumentIntelligenceLoader",
"MathpixPDFLoader",
"OnlinePDFLoader", "OnlinePDFLoader",
"PagedPDFSplitter",
"PyPDFium2Loader",
"PyPDFDirectoryLoader",
"PDFMinerLoader", "PDFMinerLoader",
"PDFMinerPDFasHTMLLoader", "PDFMinerPDFasHTMLLoader",
"PyMuPDFLoader",
"MathpixPDFLoader",
"PDFPlumberLoader", "PDFPlumberLoader",
"AmazonTextractPDFLoader", "PagedPDFSplitter",
"DocumentIntelligenceLoader", "PyMuPDFLoader",
"PyPDFDirectoryLoader",
"PyPDFium2Loader",
"UnstructuredPDFLoader",
] ]

View File

@ -31,8 +31,8 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"concatenate_rows",
"TelegramChatFileLoader",
"text_to_docs",
"TelegramChatApiLoader", "TelegramChatApiLoader",
"TelegramChatFileLoader",
"concatenate_rows",
"text_to_docs",
] ]

View File

@ -43,12 +43,12 @@ def __getattr__(name: str) -> Any:
__all__ = [ __all__ = [
"satisfies_min_unstructured_version", "UnstructuredAPIFileIOLoader",
"validate_unstructured_version", "UnstructuredAPIFileLoader",
"UnstructuredBaseLoader", "UnstructuredBaseLoader",
"UnstructuredFileIOLoader",
"UnstructuredFileLoader", "UnstructuredFileLoader",
"get_elements_from_api", "get_elements_from_api",
"UnstructuredAPIFileLoader", "satisfies_min_unstructured_version",
"UnstructuredFileIOLoader", "validate_unstructured_version",
"UnstructuredAPIFileIOLoader",
] ]

Some files were not shown because too many files have changed in this diff Show More