From d141f63250e7d8e6587dcb502dee750f75911921 Mon Sep 17 00:00:00 2001 From: Bagatur Date: Mon, 20 Nov 2023 11:36:25 -0800 Subject: [PATCH] runnable -> runnables --- .../callbacks/tracers/root_listeners.py | 2 +- libs/core/langchain_core/chat_model.py | 2 +- libs/core/langchain_core/llm.py | 4 ++-- .../{runnable => runnables}/__init__.py | 14 +++++------ .../{runnable => runnables}/base.py | 24 +++++++++---------- .../{runnable => runnables}/branch.py | 8 +++---- .../{runnable => runnables}/config.py | 2 +- .../{runnable => runnables}/configurable.py | 6 ++--- .../{runnable => runnables}/fallbacks.py | 8 +++---- .../{runnable => runnables}/history.py | 10 ++++---- .../{runnable => runnables}/passthrough.py | 10 ++++---- .../{runnable => runnables}/retry.py | 4 ++-- .../{runnable => runnables}/router.py | 6 ++--- .../{runnable => runnables}/utils.py | 0 .../langchain_core/schema/language_model.py | 2 +- .../langchain_core/schema/output_parser.py | 2 +- .../langchain_core/schema/prompt_template.py | 2 +- libs/core/langchain_core/schema/retriever.py | 2 +- libs/core/langchain_core/tool.py | 2 +- libs/core/tests/unit_tests/fake/llm.py | 2 +- .../tests/unit_tests/runnable/test_config.py | 2 +- .../tests/unit_tests/runnable/test_history.py | 4 ++-- .../unit_tests/runnable/test_runnable.py | 6 ++--- .../tests/unit_tests/runnable/test_utils.py | 2 +- libs/langchain/langchain/agents/agent.py | 2 +- .../langchain/agents/openai_assistant/base.py | 2 +- libs/langchain/langchain/chains/base.py | 2 +- .../chains/combine_documents/base.py | 2 +- .../chains/combine_documents/map_reduce.py | 2 +- .../chains/combine_documents/map_rerank.py | 2 +- .../chains/conversational_retrieval/base.py | 2 +- libs/langchain/langchain/chains/llm.py | 4 ++-- .../langchain/chains/openai_functions/base.py | 2 +- .../chains/openai_tools/extraction.py | 2 +- .../chains/query_constructor/base.py | 2 +- .../langchain/chains/sql_database/query.py | 2 +- .../langchain/langchain/chat_models/openai.py | 2 +- libs/langchain/langchain/llms/fake.py | 2 +- .../langchain/retrievers/self_query/base.py | 2 +- libs/langchain/langchain/runnables/hub.py | 2 +- .../langchain/runnables/openai_functions.py | 4 ++-- .../langchain/schema/runnable/__init__.py | 14 +++++------ .../langchain/schema/runnable/base.py | 2 +- .../langchain/schema/runnable/branch.py | 2 +- .../langchain/schema/runnable/config.py | 2 +- .../langchain/schema/runnable/configurable.py | 2 +- .../langchain/schema/runnable/fallbacks.py | 2 +- .../langchain/schema/runnable/history.py | 2 +- .../langchain/schema/runnable/passthrough.py | 2 +- .../langchain/schema/runnable/retry.py | 2 +- .../langchain/schema/runnable/router.py | 2 +- .../langchain/schema/runnable/utils.py | 2 +- .../smith/evaluation/runner_utils.py | 6 ++--- .../llms/test_opaqueprompts.py | 2 +- .../tests/unit_tests/runnables/test_hub.py | 2 +- 55 files changed, 104 insertions(+), 104 deletions(-) rename libs/core/langchain_core/{runnable => runnables}/__init__.py (76%) rename libs/core/langchain_core/{runnable => runnables}/base.py (99%) rename libs/core/langchain_core/{runnable => runnables}/branch.py (97%) rename libs/core/langchain_core/{runnable => runnables}/config.py (99%) rename libs/core/langchain_core/{runnable => runnables}/configurable.py (98%) rename libs/core/langchain_core/{runnable => runnables}/fallbacks.py (98%) rename libs/core/langchain_core/{runnable => runnables}/history.py (96%) rename libs/core/langchain_core/{runnable => runnables}/passthrough.py (97%) rename libs/core/langchain_core/{runnable => runnables}/retry.py (98%) rename libs/core/langchain_core/{runnable => runnables}/router.py (97%) rename libs/core/langchain_core/{runnable => runnables}/utils.py (100%) diff --git a/libs/core/langchain_core/callbacks/tracers/root_listeners.py b/libs/core/langchain_core/callbacks/tracers/root_listeners.py index 386f4a6dc7ddf..a693ae1f1a503 100644 --- a/libs/core/langchain_core/callbacks/tracers/root_listeners.py +++ b/libs/core/langchain_core/callbacks/tracers/root_listeners.py @@ -3,7 +3,7 @@ from langchain_core.callbacks.tracers.base import BaseTracer from langchain_core.callbacks.tracers.schemas import Run -from langchain_core.runnable.config import ( +from langchain_core.runnables.config import ( RunnableConfig, call_func_with_variable_args, ) diff --git a/libs/core/langchain_core/chat_model.py b/libs/core/langchain_core/chat_model.py index 51d4bffb5bcb2..ebe77711d39c4 100644 --- a/libs/core/langchain_core/chat_model.py +++ b/libs/core/langchain_core/chat_model.py @@ -27,7 +27,7 @@ from langchain_core.prompts.base import StringPromptValue from langchain_core.prompts.chat import ChatPromptValue from langchain_core.pydantic_v1 import Field, root_validator -from langchain_core.runnable import RunnableConfig +from langchain_core.runnables import RunnableConfig from langchain_core.schema import ( ChatGeneration, ChatResult, diff --git a/libs/core/langchain_core/llm.py b/libs/core/langchain_core/llm.py index c2765af29c833..b48f9230a8800 100644 --- a/libs/core/langchain_core/llm.py +++ b/libs/core/langchain_core/llm.py @@ -50,8 +50,8 @@ from langchain_core.prompts.base import StringPromptValue from langchain_core.prompts.chat import ChatPromptValue from langchain_core.pydantic_v1 import Field, root_validator, validator -from langchain_core.runnable import RunnableConfig -from langchain_core.runnable.config import get_config_list +from langchain_core.runnables import RunnableConfig +from langchain_core.runnables.config import get_config_list from langchain_core.schema import Generation, LLMResult, PromptValue, RunInfo from langchain_core.schema.language_model import BaseLanguageModel, LanguageModelInput from langchain_core.schema.messages import AIMessage, BaseMessage, get_buffer_string diff --git a/libs/core/langchain_core/runnable/__init__.py b/libs/core/langchain_core/runnables/__init__.py similarity index 76% rename from libs/core/langchain_core/runnable/__init__.py rename to libs/core/langchain_core/runnables/__init__.py index af4fecce3ebc5..3a1f555d1c889 100644 --- a/libs/core/langchain_core/runnable/__init__.py +++ b/libs/core/langchain_core/runnables/__init__.py @@ -14,7 +14,7 @@ This module contains schema and implementation of LangChain Runnables primitives. """ -from langchain_core.runnable.base import ( +from langchain_core.runnables.base import ( Runnable, RunnableBinding, RunnableGenerator, @@ -24,12 +24,12 @@ RunnableSequence, RunnableSerializable, ) -from langchain_core.runnable.branch import RunnableBranch -from langchain_core.runnable.config import RunnableConfig, patch_config -from langchain_core.runnable.fallbacks import RunnableWithFallbacks -from langchain_core.runnable.passthrough import RunnablePassthrough -from langchain_core.runnable.router import RouterInput, RouterRunnable -from langchain_core.runnable.utils import ( +from langchain_core.runnables.branch import RunnableBranch +from langchain_core.runnables.config import RunnableConfig, patch_config +from langchain_core.runnables.fallbacks import RunnableWithFallbacks +from langchain_core.runnables.passthrough import RunnablePassthrough +from langchain_core.runnables.router import RouterInput, RouterRunnable +from langchain_core.runnables.utils import ( ConfigurableField, ConfigurableFieldMultiOption, ConfigurableFieldSingleOption, diff --git a/libs/core/langchain_core/runnable/base.py b/libs/core/langchain_core/runnables/base.py similarity index 99% rename from libs/core/langchain_core/runnable/base.py rename to libs/core/langchain_core/runnables/base.py index f35687597e993..384370f9dabba 100644 --- a/libs/core/langchain_core/runnable/base.py +++ b/libs/core/langchain_core/runnables/base.py @@ -38,14 +38,14 @@ ) from langchain_core.callbacks.tracers.log_stream import RunLog, RunLogPatch from langchain_core.callbacks.tracers.root_listeners import Listener - from langchain_core.runnable.fallbacks import ( + from langchain_core.runnables.fallbacks import ( RunnableWithFallbacks as RunnableWithFallbacksT, ) from langchain_core.load.dump import dumpd from langchain_core.load.serializable import Serializable from langchain_core.pydantic_v1 import BaseModel, Field, create_model -from langchain_core.runnable.config import ( +from langchain_core.runnables.config import ( RunnableConfig, acall_func_with_variable_args, call_func_with_variable_args, @@ -57,7 +57,7 @@ merge_configs, patch_config, ) -from langchain_core.runnable.utils import ( +from langchain_core.runnables.utils import ( AddableDict, AnyConfigurableField, ConfigurableField, @@ -126,7 +126,7 @@ class Runnable(Generic[Input, Output], ABC): .. code-block:: python - from langchain_core.runnable import RunnableLambda + from langchain_core.runnables import RunnableLambda # A RunnableSequence constructed using the `|` operator sequence = RunnableLambda(lambda x: x + 1) | RunnableLambda(lambda x: x * 2) @@ -154,7 +154,7 @@ class Runnable(Generic[Input, Output], ABC): .. code-block:: python - from langchain_core.runnable import RunnableLambda + from langchain_core.runnables import RunnableLambda import random @@ -777,7 +777,7 @@ def with_retry( Returns: A new Runnable that retries the original runnable on exceptions. """ - from langchain_core.runnable.retry import RunnableRetry + from langchain_core.runnables.retry import RunnableRetry return RunnableRetry( bound=self, @@ -811,7 +811,7 @@ def with_fallbacks( A new Runnable that will try the original runnable, and then each fallback in order, upon failures. """ - from langchain_core.runnable.fallbacks import RunnableWithFallbacks + from langchain_core.runnables.fallbacks import RunnableWithFallbacks return RunnableWithFallbacks( runnable=self, @@ -1189,7 +1189,7 @@ class RunnableSerializable(Serializable, Runnable[Input, Output]): def configurable_fields( self, **kwargs: AnyConfigurableField ) -> RunnableSerializable[Input, Output]: - from langchain_core.runnable.configurable import RunnableConfigurableFields + from langchain_core.runnables.configurable import RunnableConfigurableFields for key in kwargs: if key not in self.__fields__: @@ -1206,7 +1206,7 @@ def configurable_alternatives( default_key: str = "default", **kwargs: Union[Runnable[Input, Output], Callable[[], Runnable[Input, Output]]], ) -> RunnableSerializable[Input, Output]: - from langchain_core.runnable.configurable import ( + from langchain_core.runnables.configurable import ( RunnableConfigurableAlternatives, ) @@ -1254,7 +1254,7 @@ class RunnableSequence(RunnableSerializable[Input, Output]): .. code-block:: python - from langchain_core.runnable import RunnableLambda + from langchain_core.runnables import RunnableLambda def add_one(x: int) -> int: return x + 1 @@ -1331,7 +1331,7 @@ def OutputType(self) -> Type[Output]: def get_input_schema( self, config: Optional[RunnableConfig] = None ) -> Type[BaseModel]: - from langchain_core.runnable.passthrough import RunnableAssign + from langchain_core.runnables.passthrough import RunnableAssign if isinstance(self.first, RunnableAssign): first = cast(RunnableAssign, self.first) @@ -2273,7 +2273,7 @@ class RunnableLambda(Runnable[Input, Output]): .. code-block:: python # This is a RunnableLambda - from langchain_core.runnable import RunnableLambda + from langchain_core.runnables import RunnableLambda def add_one(x: int) -> int: return x + 1 diff --git a/libs/core/langchain_core/runnable/branch.py b/libs/core/langchain_core/runnables/branch.py similarity index 97% rename from libs/core/langchain_core/runnable/branch.py rename to libs/core/langchain_core/runnables/branch.py index c21b69cec298b..96e9685dc6d5e 100644 --- a/libs/core/langchain_core/runnable/branch.py +++ b/libs/core/langchain_core/runnables/branch.py @@ -14,19 +14,19 @@ from langchain_core.load.dump import dumpd from langchain_core.pydantic_v1 import BaseModel -from langchain_core.runnable.base import ( +from langchain_core.runnables.base import ( Runnable, RunnableLike, RunnableSerializable, coerce_to_runnable, ) -from langchain_core.runnable.config import ( +from langchain_core.runnables.config import ( RunnableConfig, ensure_config, get_callback_manager_for_config, patch_config, ) -from langchain_core.runnable.utils import ( +from langchain_core.runnables.utils import ( ConfigurableFieldSpec, Input, Output, @@ -49,7 +49,7 @@ class RunnableBranch(RunnableSerializable[Input, Output]): .. code-block:: python - from langchain_core.runnable import RunnableBranch + from langchain_core.runnables import RunnableBranch branch = RunnableBranch( (lambda x: isinstance(x, str), lambda x: x.upper()), diff --git a/libs/core/langchain_core/runnable/config.py b/libs/core/langchain_core/runnables/config.py similarity index 99% rename from libs/core/langchain_core/runnable/config.py rename to libs/core/langchain_core/runnables/config.py index 21edd50178011..e68b7080f1dc7 100644 --- a/libs/core/langchain_core/runnable/config.py +++ b/libs/core/langchain_core/runnables/config.py @@ -17,7 +17,7 @@ from typing_extensions import TypedDict -from langchain_core.runnable.utils import ( +from langchain_core.runnables.utils import ( Input, Output, accepts_config, diff --git a/libs/core/langchain_core/runnable/configurable.py b/libs/core/langchain_core/runnables/configurable.py similarity index 98% rename from libs/core/langchain_core/runnable/configurable.py rename to libs/core/langchain_core/runnables/configurable.py index 2cc0599af2877..7d95d1570307d 100644 --- a/libs/core/langchain_core/runnable/configurable.py +++ b/libs/core/langchain_core/runnables/configurable.py @@ -19,13 +19,13 @@ from weakref import WeakValueDictionary from langchain_core.pydantic_v1 import BaseModel -from langchain_core.runnable.base import Runnable, RunnableSerializable -from langchain_core.runnable.config import ( +from langchain_core.runnables.base import Runnable, RunnableSerializable +from langchain_core.runnables.config import ( RunnableConfig, get_config_list, get_executor_for_config, ) -from langchain_core.runnable.utils import ( +from langchain_core.runnables.utils import ( AnyConfigurableField, ConfigurableField, ConfigurableFieldMultiOption, diff --git a/libs/core/langchain_core/runnable/fallbacks.py b/libs/core/langchain_core/runnables/fallbacks.py similarity index 98% rename from libs/core/langchain_core/runnable/fallbacks.py rename to libs/core/langchain_core/runnables/fallbacks.py index c042f70ec5c52..1959b100c8e87 100644 --- a/libs/core/langchain_core/runnable/fallbacks.py +++ b/libs/core/langchain_core/runnables/fallbacks.py @@ -13,8 +13,8 @@ from langchain_core.load.dump import dumpd from langchain_core.pydantic_v1 import BaseModel -from langchain_core.runnable.base import Runnable, RunnableSerializable -from langchain_core.runnable.config import ( +from langchain_core.runnables.base import Runnable, RunnableSerializable +from langchain_core.runnables.config import ( RunnableConfig, ensure_config, get_async_callback_manager_for_config, @@ -22,7 +22,7 @@ get_config_list, patch_config, ) -from langchain_core.runnable.utils import ( +from langchain_core.runnables.utils import ( ConfigurableFieldSpec, Input, Output, @@ -67,7 +67,7 @@ class RunnableWithFallbacks(RunnableSerializable[Input, Output]): from langchain_core.prompts import PromptTemplate from langchain_core.schema.output_parser import StrOutputParser - from langchain_core.runnable import RunnableLambda + from langchain_core.runnables import RunnableLambda def when_all_is_lost(inputs): return ("Looks like our LLM providers are down. " diff --git a/libs/core/langchain_core/runnable/history.py b/libs/core/langchain_core/runnables/history.py similarity index 96% rename from libs/core/langchain_core/runnable/history.py rename to libs/core/langchain_core/runnables/history.py index 5e30de4a1b4de..d8eb5814514f1 100644 --- a/libs/core/langchain_core/runnable/history.py +++ b/libs/core/langchain_core/runnables/history.py @@ -15,9 +15,9 @@ from langchain_core.load import load from langchain_core.pydantic_v1 import BaseModel, create_model -from langchain_core.runnable.base import Runnable, RunnableBindingBase, RunnableLambda -from langchain_core.runnable.passthrough import RunnablePassthrough -from langchain_core.runnable.utils import ( +from langchain_core.runnables.base import Runnable, RunnableBindingBase, RunnableLambda +from langchain_core.runnables.passthrough import RunnablePassthrough +from langchain_core.runnables.utils import ( ConfigurableFieldSpec, get_unique_config_specs, ) @@ -25,7 +25,7 @@ if TYPE_CHECKING: from langchain_core.callbacks.tracers.schemas import Run - from langchain_core.runnable.config import RunnableConfig + from langchain_core.runnables.config import RunnableConfig from langchain_core.schema.messages import BaseMessage MessagesOrDictWithMessages = Union[Sequence["BaseMessage"], Dict[str, Any]] @@ -49,7 +49,7 @@ class RunnableWithMessageHistory(RunnableBindingBase): from langchain_core.chat_models import ChatAnthropic from langchain_core.memory.chat_message_histories import RedisChatMessageHistory from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder - from langchain_core.runnable.history import RunnableWithMessageHistory + from langchain_core.runnables.history import RunnableWithMessageHistory prompt = ChatPromptTemplate.from_messages([ diff --git a/libs/core/langchain_core/runnable/passthrough.py b/libs/core/langchain_core/runnables/passthrough.py similarity index 97% rename from libs/core/langchain_core/runnable/passthrough.py rename to libs/core/langchain_core/runnables/passthrough.py index fb4e45377d9bf..37d97fb96812c 100644 --- a/libs/core/langchain_core/runnable/passthrough.py +++ b/libs/core/langchain_core/runnables/passthrough.py @@ -20,19 +20,19 @@ ) from langchain_core.pydantic_v1 import BaseModel, create_model -from langchain_core.runnable.base import ( +from langchain_core.runnables.base import ( Other, Runnable, RunnableParallel, RunnableSerializable, ) -from langchain_core.runnable.config import ( +from langchain_core.runnables.config import ( RunnableConfig, acall_func_with_variable_args, call_func_with_variable_args, get_executor_for_config, ) -from langchain_core.runnable.utils import AddableDict, ConfigurableFieldSpec +from langchain_core.runnables.utils import AddableDict, ConfigurableFieldSpec from langchain_core.utils.aiter import atee, py_anext from langchain_core.utils.iter import safetee @@ -62,7 +62,7 @@ class RunnablePassthrough(RunnableSerializable[Other, Other]): .. code-block:: python - from langchain_core.runnable import RunnablePassthrough, RunnableParallel + from langchain_core.runnables import RunnablePassthrough, RunnableParallel runnable = RunnableParallel( origin=RunnablePassthrough(), @@ -87,7 +87,7 @@ def fake_llm(prompt: str) -> str: # Fake LLM for the example .. code-block:: python - from langchain_core.runnable import RunnablePassthrough, RunnableParallel + from langchain_core.runnables import RunnablePassthrough, RunnableParallel def fake_llm(prompt: str) -> str: # Fake LLM for the example return "completion" diff --git a/libs/core/langchain_core/runnable/retry.py b/libs/core/langchain_core/runnables/retry.py similarity index 98% rename from libs/core/langchain_core/runnable/retry.py rename to libs/core/langchain_core/runnables/retry.py index e2d732126e45c..7aeb974648d14 100644 --- a/libs/core/langchain_core/runnable/retry.py +++ b/libs/core/langchain_core/runnables/retry.py @@ -21,8 +21,8 @@ wait_exponential_jitter, ) -from langchain_core.runnable.base import Input, Output, RunnableBindingBase -from langchain_core.runnable.config import RunnableConfig, patch_config +from langchain_core.runnables.base import Input, Output, RunnableBindingBase +from langchain_core.runnables.config import RunnableConfig, patch_config if TYPE_CHECKING: from langchain_core.callbacks.manager import ( diff --git a/libs/core/langchain_core/runnable/router.py b/libs/core/langchain_core/runnables/router.py similarity index 97% rename from libs/core/langchain_core/runnable/router.py rename to libs/core/langchain_core/runnables/router.py index ccac5d206538c..0413d8a911062 100644 --- a/libs/core/langchain_core/runnable/router.py +++ b/libs/core/langchain_core/runnables/router.py @@ -14,19 +14,19 @@ from typing_extensions import TypedDict -from langchain_core.runnable.base import ( +from langchain_core.runnables.base import ( Input, Output, Runnable, RunnableSerializable, coerce_to_runnable, ) -from langchain_core.runnable.config import ( +from langchain_core.runnables.config import ( RunnableConfig, get_config_list, get_executor_for_config, ) -from langchain_core.runnable.utils import ( +from langchain_core.runnables.utils import ( ConfigurableFieldSpec, gather_with_concurrency, get_unique_config_specs, diff --git a/libs/core/langchain_core/runnable/utils.py b/libs/core/langchain_core/runnables/utils.py similarity index 100% rename from libs/core/langchain_core/runnable/utils.py rename to libs/core/langchain_core/runnables/utils.py diff --git a/libs/core/langchain_core/schema/language_model.py b/libs/core/langchain_core/schema/language_model.py index 77b86cb819a20..df22e8b327654 100644 --- a/libs/core/langchain_core/schema/language_model.py +++ b/libs/core/langchain_core/schema/language_model.py @@ -15,7 +15,7 @@ from typing_extensions import TypeAlias -from langchain_core.runnable import RunnableSerializable +from langchain_core.runnables import RunnableSerializable from langchain_core.schema.messages import AnyMessage, BaseMessage, get_buffer_string from langchain_core.schema.output import LLMResult from langchain_core.schema.prompt import PromptValue diff --git a/libs/core/langchain_core/schema/output_parser.py b/libs/core/langchain_core/schema/output_parser.py index ce1130b55d3c0..5dd2ebfb2ace2 100644 --- a/libs/core/langchain_core/schema/output_parser.py +++ b/libs/core/langchain_core/schema/output_parser.py @@ -18,7 +18,7 @@ from typing_extensions import get_args -from langchain_core.runnable import RunnableConfig, RunnableSerializable +from langchain_core.runnables import RunnableConfig, RunnableSerializable from langchain_core.schema.messages import AnyMessage, BaseMessage, BaseMessageChunk from langchain_core.schema.output import ( ChatGeneration, diff --git a/libs/core/langchain_core/schema/prompt_template.py b/libs/core/langchain_core/schema/prompt_template.py index ad2c8611b667a..2985c5bb06c7f 100644 --- a/libs/core/langchain_core/schema/prompt_template.py +++ b/libs/core/langchain_core/schema/prompt_template.py @@ -8,7 +8,7 @@ import yaml from langchain_core.pydantic_v1 import BaseModel, Field, create_model, root_validator -from langchain_core.runnable import RunnableConfig, RunnableSerializable +from langchain_core.runnables import RunnableConfig, RunnableSerializable from langchain_core.schema.document import Document from langchain_core.schema.output_parser import BaseOutputParser from langchain_core.schema.prompt import PromptValue diff --git a/libs/core/langchain_core/schema/retriever.py b/libs/core/langchain_core/schema/retriever.py index e1931043d0b6b..1d8d177831747 100644 --- a/libs/core/langchain_core/schema/retriever.py +++ b/libs/core/langchain_core/schema/retriever.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional from langchain_core.load.dump import dumpd -from langchain_core.runnable import RunnableConfig, RunnableSerializable +from langchain_core.runnables import RunnableConfig, RunnableSerializable from langchain_core.schema.document import Document if TYPE_CHECKING: diff --git a/libs/core/langchain_core/tool.py b/libs/core/langchain_core/tool.py index fb2463a74a39d..9f362bfa8e33e 100644 --- a/libs/core/langchain_core/tool.py +++ b/libs/core/langchain_core/tool.py @@ -26,7 +26,7 @@ root_validator, validate_arguments, ) -from langchain_core.runnable import Runnable, RunnableConfig, RunnableSerializable +from langchain_core.runnables import Runnable, RunnableConfig, RunnableSerializable class SchemaAnnotationError(TypeError): diff --git a/libs/core/tests/unit_tests/fake/llm.py b/libs/core/tests/unit_tests/fake/llm.py index 0cc0e41af00a7..fa1d92b104332 100644 --- a/libs/core/tests/unit_tests/fake/llm.py +++ b/libs/core/tests/unit_tests/fake/llm.py @@ -7,7 +7,7 @@ CallbackManagerForLLMRun, ) from langchain_core.llm import LLM -from langchain_core.runnable import RunnableConfig +from langchain_core.runnables import RunnableConfig from langchain_core.schema.language_model import LanguageModelInput diff --git a/libs/core/tests/unit_tests/runnable/test_config.py b/libs/core/tests/unit_tests/runnable/test_config.py index 4107e172eccdc..e15c5e48a4a2b 100644 --- a/libs/core/tests/unit_tests/runnable/test_config.py +++ b/libs/core/tests/unit_tests/runnable/test_config.py @@ -2,7 +2,7 @@ from langchain_core.callbacks.stdout import StdOutCallbackHandler from langchain_core.callbacks.streaming_stdout import StreamingStdOutCallbackHandler from langchain_core.callbacks.tracers.stdout import ConsoleCallbackHandler -from langchain_core.runnable.config import RunnableConfig, merge_configs +from langchain_core.runnables.config import RunnableConfig, merge_configs def test_merge_config_callbacks() -> None: diff --git a/libs/core/tests/unit_tests/runnable/test_history.py b/libs/core/tests/unit_tests/runnable/test_history.py index 11a0d63eaac0d..534ff12b44c81 100644 --- a/libs/core/tests/unit_tests/runnable/test_history.py +++ b/libs/core/tests/unit_tests/runnable/test_history.py @@ -1,8 +1,8 @@ from typing import Any, Callable, Sequence, Union from langchain_core.pydantic_v1 import BaseModel -from langchain_core.runnable import RunnableConfig, RunnableLambda -from langchain_core.runnable.history import RunnableWithMessageHistory +from langchain_core.runnables import RunnableConfig, RunnableLambda +from langchain_core.runnables.history import RunnableWithMessageHistory from langchain_core.schema import AIMessage, BaseMessage, HumanMessage from tests.unit_tests.fake.memory import ChatMessageHistory diff --git a/libs/core/tests/unit_tests/runnable/test_runnable.py b/libs/core/tests/unit_tests/runnable/test_runnable.py index e9fba125afb12..21c5a28b689b8 100644 --- a/libs/core/tests/unit_tests/runnable/test_runnable.py +++ b/libs/core/tests/unit_tests/runnable/test_runnable.py @@ -42,7 +42,7 @@ SystemMessagePromptTemplate, ) from langchain_core.pydantic_v1 import BaseModel -from langchain_core.runnable import ( +from langchain_core.runnables import ( RouterRunnable, Runnable, RunnableBranch, @@ -53,12 +53,12 @@ RunnableSequence, RunnableWithFallbacks, ) -from langchain_core.runnable.base import ( +from langchain_core.runnables.base import ( ConfigurableField, RunnableBinding, RunnableGenerator, ) -from langchain_core.runnable.utils import ( +from langchain_core.runnables.utils import ( ConfigurableFieldMultiOption, ConfigurableFieldSingleOption, add, diff --git a/libs/core/tests/unit_tests/runnable/test_utils.py b/libs/core/tests/unit_tests/runnable/test_utils.py index f0d7a583659f2..1bbf5a8a91a59 100644 --- a/libs/core/tests/unit_tests/runnable/test_utils.py +++ b/libs/core/tests/unit_tests/runnable/test_utils.py @@ -3,7 +3,7 @@ import pytest -from langchain_core.runnable.utils import ( +from langchain_core.runnables.utils import ( get_lambda_source, indent_lines_after_first, ) diff --git a/libs/langchain/langchain/agents/agent.py b/libs/langchain/langchain/agents/agent.py index 76ccc90e7e2aa..905826ccf2f9c 100644 --- a/libs/langchain/langchain/agents/agent.py +++ b/libs/langchain/langchain/agents/agent.py @@ -22,7 +22,7 @@ from langchain_core.prompts.few_shot import FewShotPromptTemplate from langchain_core.prompts.prompt import PromptTemplate from langchain_core.pydantic_v1 import BaseModel, root_validator -from langchain_core.runnable import Runnable +from langchain_core.runnables import Runnable from langchain_core.schema import ( AgentAction, AgentFinish, diff --git a/libs/langchain/langchain/agents/openai_assistant/base.py b/libs/langchain/langchain/agents/openai_assistant/base.py index f9fac1918ad78..19edcacec904a 100644 --- a/libs/langchain/langchain/agents/openai_assistant/base.py +++ b/libs/langchain/langchain/agents/openai_assistant/base.py @@ -7,7 +7,7 @@ from langchain_core.load import dumpd from langchain_core.pydantic_v1 import Field -from langchain_core.runnable import RunnableConfig, RunnableSerializable +from langchain_core.runnables import RunnableConfig, RunnableSerializable from langchain_core.schema.agent import AgentAction, AgentFinish from langchain.callbacks.manager import CallbackManager diff --git a/libs/langchain/langchain/chains/base.py b/libs/langchain/langchain/chains/base.py index 2042ec3eac43a..52e5c20c8ff6b 100644 --- a/libs/langchain/langchain/chains/base.py +++ b/libs/langchain/langchain/chains/base.py @@ -17,7 +17,7 @@ root_validator, validator, ) -from langchain_core.runnable import RunnableConfig, RunnableSerializable +from langchain_core.runnables import RunnableConfig, RunnableSerializable from langchain_core.schema import RUN_KEY, BaseMemory, RunInfo from langchain.callbacks.base import BaseCallbackManager diff --git a/libs/langchain/langchain/chains/combine_documents/base.py b/libs/langchain/langchain/chains/combine_documents/base.py index 98dee431b0792..23192de2abc81 100644 --- a/libs/langchain/langchain/chains/combine_documents/base.py +++ b/libs/langchain/langchain/chains/combine_documents/base.py @@ -4,7 +4,7 @@ from typing import Any, Dict, List, Optional, Tuple, Type from langchain_core.pydantic_v1 import BaseModel, Field, create_model -from langchain_core.runnable.config import RunnableConfig +from langchain_core.runnables.config import RunnableConfig from langchain.callbacks.manager import ( AsyncCallbackManagerForChainRun, diff --git a/libs/langchain/langchain/chains/combine_documents/map_reduce.py b/libs/langchain/langchain/chains/combine_documents/map_reduce.py index e81288a4b8328..02672804e5b95 100644 --- a/libs/langchain/langchain/chains/combine_documents/map_reduce.py +++ b/libs/langchain/langchain/chains/combine_documents/map_reduce.py @@ -5,7 +5,7 @@ from typing import Any, Dict, List, Optional, Tuple, Type from langchain_core.pydantic_v1 import BaseModel, Extra, create_model, root_validator -from langchain_core.runnable.config import RunnableConfig +from langchain_core.runnables.config import RunnableConfig from langchain.callbacks.manager import Callbacks from langchain.chains.combine_documents.base import BaseCombineDocumentsChain diff --git a/libs/langchain/langchain/chains/combine_documents/map_rerank.py b/libs/langchain/langchain/chains/combine_documents/map_rerank.py index ddc2887934a04..f051bad2e3243 100644 --- a/libs/langchain/langchain/chains/combine_documents/map_rerank.py +++ b/libs/langchain/langchain/chains/combine_documents/map_rerank.py @@ -5,7 +5,7 @@ from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union, cast from langchain_core.pydantic_v1 import BaseModel, Extra, create_model, root_validator -from langchain_core.runnable.config import RunnableConfig +from langchain_core.runnables.config import RunnableConfig from langchain.callbacks.manager import Callbacks from langchain.chains.combine_documents.base import BaseCombineDocumentsChain diff --git a/libs/langchain/langchain/chains/conversational_retrieval/base.py b/libs/langchain/langchain/chains/conversational_retrieval/base.py index a2794205ad406..3624c874733a2 100644 --- a/libs/langchain/langchain/chains/conversational_retrieval/base.py +++ b/libs/langchain/langchain/chains/conversational_retrieval/base.py @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union from langchain_core.pydantic_v1 import BaseModel, Extra, Field, root_validator -from langchain_core.runnable.config import RunnableConfig +from langchain_core.runnables.config import RunnableConfig from langchain_core.schema import BasePromptTemplate, BaseRetriever, Document from langchain_core.schema.language_model import BaseLanguageModel from langchain_core.schema.messages import BaseMessage diff --git a/libs/langchain/langchain/chains/llm.py b/libs/langchain/langchain/chains/llm.py index 4c8451cc04296..aec49e297032c 100644 --- a/libs/langchain/langchain/chains/llm.py +++ b/libs/langchain/langchain/chains/llm.py @@ -7,13 +7,13 @@ from langchain_core.load.dump import dumpd from langchain_core.prompts.prompt import PromptTemplate from langchain_core.pydantic_v1 import Extra, Field -from langchain_core.runnable import ( +from langchain_core.runnables import ( Runnable, RunnableBinding, RunnableBranch, RunnableWithFallbacks, ) -from langchain_core.runnable.configurable import DynamicRunnable +from langchain_core.runnables.configurable import DynamicRunnable from langchain_core.schema import ( BaseLLMOutputParser, BaseMessage, diff --git a/libs/langchain/langchain/chains/openai_functions/base.py b/libs/langchain/langchain/chains/openai_functions/base.py index 43b73c90c53a7..5f2acff309094 100644 --- a/libs/langchain/langchain/chains/openai_functions/base.py +++ b/libs/langchain/langchain/chains/openai_functions/base.py @@ -15,7 +15,7 @@ from langchain_core.prompts import BasePromptTemplate from langchain_core.pydantic_v1 import BaseModel -from langchain_core.runnable import Runnable +from langchain_core.runnables import Runnable from langchain_core.schema import BaseLLMOutputParser from langchain_core.schema.output_parser import ( BaseGenerationOutputParser, diff --git a/libs/langchain/langchain/chains/openai_tools/extraction.py b/libs/langchain/langchain/chains/openai_tools/extraction.py index dc616365e4fe2..95bb3e1bf68a4 100644 --- a/libs/langchain/langchain/chains/openai_tools/extraction.py +++ b/libs/langchain/langchain/chains/openai_tools/extraction.py @@ -2,7 +2,7 @@ from langchain_core.prompts import ChatPromptTemplate from langchain_core.pydantic_v1 import BaseModel -from langchain_core.runnable import Runnable +from langchain_core.runnables import Runnable from langchain_core.schema.language_model import BaseLanguageModel from langchain.output_parsers import PydanticToolsParser diff --git a/libs/langchain/langchain/chains/query_constructor/base.py b/libs/langchain/langchain/chains/query_constructor/base.py index 90767cf6de4df..4f3b69bed5b50 100644 --- a/libs/langchain/langchain/chains/query_constructor/base.py +++ b/libs/langchain/langchain/chains/query_constructor/base.py @@ -5,7 +5,7 @@ from typing import Any, Callable, List, Optional, Sequence, Tuple, Union, cast from langchain_core.prompts.few_shot import FewShotPromptTemplate -from langchain_core.runnable import Runnable +from langchain_core.runnables import Runnable from langchain_core.schema import ( BaseOutputParser, BasePromptTemplate, diff --git a/libs/langchain/langchain/chains/sql_database/query.py b/libs/langchain/langchain/chains/sql_database/query.py index 0abec2f5b7085..b3d19f2857575 100644 --- a/libs/langchain/langchain/chains/sql_database/query.py +++ b/libs/langchain/langchain/chains/sql_database/query.py @@ -1,6 +1,6 @@ from typing import List, Optional, TypedDict, Union -from langchain_core.runnable import Runnable, RunnableParallel +from langchain_core.runnables import Runnable, RunnableParallel from langchain_core.schema.language_model import BaseLanguageModel from langchain_core.schema.output_parser import NoOpOutputParser from langchain_core.schema.prompt_template import BasePromptTemplate diff --git a/libs/langchain/langchain/chat_models/openai.py b/libs/langchain/langchain/chat_models/openai.py index 81a0acf83229c..21ca6360aa611 100644 --- a/libs/langchain/langchain/chat_models/openai.py +++ b/libs/langchain/langchain/chat_models/openai.py @@ -21,7 +21,7 @@ ) from langchain_core.pydantic_v1 import BaseModel, Field, root_validator -from langchain_core.runnable import Runnable +from langchain_core.runnables import Runnable from langchain_core.schema import ChatGeneration, ChatResult from langchain_core.schema.language_model import LanguageModelInput from langchain_core.schema.messages import ( diff --git a/libs/langchain/langchain/llms/fake.py b/libs/langchain/langchain/llms/fake.py index 6ab45aa86cedd..f77f919e6c92b 100644 --- a/libs/langchain/langchain/llms/fake.py +++ b/libs/langchain/langchain/llms/fake.py @@ -2,7 +2,7 @@ import time from typing import Any, AsyncIterator, Iterator, List, Mapping, Optional -from langchain_core.runnable import RunnableConfig +from langchain_core.runnables import RunnableConfig from langchain_core.schema.language_model import LanguageModelInput from langchain.callbacks.manager import ( diff --git a/libs/langchain/langchain/retrievers/self_query/base.py b/libs/langchain/langchain/retrievers/self_query/base.py index 6731869ed3957..7739dfbe72cc4 100644 --- a/libs/langchain/langchain/retrievers/self_query/base.py +++ b/libs/langchain/langchain/retrievers/self_query/base.py @@ -3,7 +3,7 @@ from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union from langchain_core.pydantic_v1 import BaseModel, Field, root_validator -from langchain_core.runnable import Runnable +from langchain_core.runnables import Runnable from langchain_core.schema import BaseRetriever, Document from langchain_core.schema.language_model import BaseLanguageModel from langchain_core.schema.vectorstore import VectorStore diff --git a/libs/langchain/langchain/runnables/hub.py b/libs/langchain/langchain/runnables/hub.py index 711f145a84c21..71fad87ba671d 100644 --- a/libs/langchain/langchain/runnables/hub.py +++ b/libs/langchain/langchain/runnables/hub.py @@ -1,6 +1,6 @@ from typing import Any, Optional -from langchain_core.runnable.base import Input, Output, RunnableBindingBase +from langchain_core.runnables.base import Input, Output, RunnableBindingBase class HubRunnable(RunnableBindingBase[Input, Output]): diff --git a/libs/langchain/langchain/runnables/openai_functions.py b/libs/langchain/langchain/runnables/openai_functions.py index 67b3cc16e10a8..f03d76b6495b8 100644 --- a/libs/langchain/langchain/runnables/openai_functions.py +++ b/libs/langchain/langchain/runnables/openai_functions.py @@ -1,8 +1,8 @@ from operator import itemgetter from typing import Any, Callable, List, Mapping, Optional, Union -from langchain_core.runnable import RouterRunnable, Runnable -from langchain_core.runnable.base import RunnableBindingBase +from langchain_core.runnables import RouterRunnable, Runnable +from langchain_core.runnables.base import RunnableBindingBase from langchain_core.schema.messages import BaseMessage from typing_extensions import TypedDict diff --git a/libs/langchain/langchain/schema/runnable/__init__.py b/libs/langchain/langchain/schema/runnable/__init__.py index af4fecce3ebc5..3a1f555d1c889 100644 --- a/libs/langchain/langchain/schema/runnable/__init__.py +++ b/libs/langchain/langchain/schema/runnable/__init__.py @@ -14,7 +14,7 @@ This module contains schema and implementation of LangChain Runnables primitives. """ -from langchain_core.runnable.base import ( +from langchain_core.runnables.base import ( Runnable, RunnableBinding, RunnableGenerator, @@ -24,12 +24,12 @@ RunnableSequence, RunnableSerializable, ) -from langchain_core.runnable.branch import RunnableBranch -from langchain_core.runnable.config import RunnableConfig, patch_config -from langchain_core.runnable.fallbacks import RunnableWithFallbacks -from langchain_core.runnable.passthrough import RunnablePassthrough -from langchain_core.runnable.router import RouterInput, RouterRunnable -from langchain_core.runnable.utils import ( +from langchain_core.runnables.branch import RunnableBranch +from langchain_core.runnables.config import RunnableConfig, patch_config +from langchain_core.runnables.fallbacks import RunnableWithFallbacks +from langchain_core.runnables.passthrough import RunnablePassthrough +from langchain_core.runnables.router import RouterInput, RouterRunnable +from langchain_core.runnables.utils import ( ConfigurableField, ConfigurableFieldMultiOption, ConfigurableFieldSingleOption, diff --git a/libs/langchain/langchain/schema/runnable/base.py b/libs/langchain/langchain/schema/runnable/base.py index 4a348f382ae74..201c1a2c8163b 100644 --- a/libs/langchain/langchain/schema/runnable/base.py +++ b/libs/langchain/langchain/schema/runnable/base.py @@ -1,4 +1,4 @@ -from langchain_core.runnable.base import ( +from langchain_core.runnables.base import ( Runnable, RunnableBinding, RunnableBindingBase, diff --git a/libs/langchain/langchain/schema/runnable/branch.py b/libs/langchain/langchain/schema/runnable/branch.py index 58fcee2b4b16c..ed83f197aa0b3 100644 --- a/libs/langchain/langchain/schema/runnable/branch.py +++ b/libs/langchain/langchain/schema/runnable/branch.py @@ -1,3 +1,3 @@ -from langchain_core.runnable.branch import RunnableBranch +from langchain_core.runnables.branch import RunnableBranch __all__ = ["RunnableBranch"] diff --git a/libs/langchain/langchain/schema/runnable/config.py b/libs/langchain/langchain/schema/runnable/config.py index 9786d19b066d2..0906d862cf308 100644 --- a/libs/langchain/langchain/schema/runnable/config.py +++ b/libs/langchain/langchain/schema/runnable/config.py @@ -1,4 +1,4 @@ -from langchain_core.runnable.config import ( +from langchain_core.runnables.config import ( EmptyDict, RunnableConfig, call_func_with_variable_args, diff --git a/libs/langchain/langchain/schema/runnable/configurable.py b/libs/langchain/langchain/schema/runnable/configurable.py index e134229f05b16..a1463d57466c6 100644 --- a/libs/langchain/langchain/schema/runnable/configurable.py +++ b/libs/langchain/langchain/schema/runnable/configurable.py @@ -1,4 +1,4 @@ -from langchain_core.runnable.configurable import ( +from langchain_core.runnables.configurable import ( DynamicRunnable, RunnableConfigurableAlternatives, RunnableConfigurableFields, diff --git a/libs/langchain/langchain/schema/runnable/fallbacks.py b/libs/langchain/langchain/schema/runnable/fallbacks.py index e5184b412977c..7a54468d77487 100644 --- a/libs/langchain/langchain/schema/runnable/fallbacks.py +++ b/libs/langchain/langchain/schema/runnable/fallbacks.py @@ -1,3 +1,3 @@ -from langchain_core.runnable.fallbacks import RunnableWithFallbacks +from langchain_core.runnables.fallbacks import RunnableWithFallbacks __all__ = ["RunnableWithFallbacks"] diff --git a/libs/langchain/langchain/schema/runnable/history.py b/libs/langchain/langchain/schema/runnable/history.py index d00b02b0f7117..a7cba8f299c84 100644 --- a/libs/langchain/langchain/schema/runnable/history.py +++ b/libs/langchain/langchain/schema/runnable/history.py @@ -1,3 +1,3 @@ -from langchain_core.runnable.history import RunnableWithMessageHistory +from langchain_core.runnables.history import RunnableWithMessageHistory __all__ = ["RunnableWithMessageHistory"] diff --git a/libs/langchain/langchain/schema/runnable/passthrough.py b/libs/langchain/langchain/schema/runnable/passthrough.py index 5e8666917773e..81141a7d3634d 100644 --- a/libs/langchain/langchain/schema/runnable/passthrough.py +++ b/libs/langchain/langchain/schema/runnable/passthrough.py @@ -1,4 +1,4 @@ -from langchain_core.runnable.passthrough import ( +from langchain_core.runnables.passthrough import ( RunnableAssign, RunnablePassthrough, identity, diff --git a/libs/langchain/langchain/schema/runnable/retry.py b/libs/langchain/langchain/schema/runnable/retry.py index e23a4e7747bf4..4e1f4dbcc2e71 100644 --- a/libs/langchain/langchain/schema/runnable/retry.py +++ b/libs/langchain/langchain/schema/runnable/retry.py @@ -1,3 +1,3 @@ -from langchain_core.runnable.retry import RunnableRetry +from langchain_core.runnables.retry import RunnableRetry __all__ = ["RunnableRetry"] diff --git a/libs/langchain/langchain/schema/runnable/router.py b/libs/langchain/langchain/schema/runnable/router.py index 06f1a1490cff6..259dd677c988d 100644 --- a/libs/langchain/langchain/schema/runnable/router.py +++ b/libs/langchain/langchain/schema/runnable/router.py @@ -1,3 +1,3 @@ -from langchain_core.runnable.router import RouterInput, RouterRunnable +from langchain_core.runnables.router import RouterInput, RouterRunnable __all__ = ["RouterInput", "RouterRunnable"] diff --git a/libs/langchain/langchain/schema/runnable/utils.py b/libs/langchain/langchain/schema/runnable/utils.py index b8532b56824ff..020d23f546900 100644 --- a/libs/langchain/langchain/schema/runnable/utils.py +++ b/libs/langchain/langchain/schema/runnable/utils.py @@ -1,4 +1,4 @@ -from langchain_core.runnable.utils import ( +from langchain_core.runnables.utils import ( AddableDict, ConfigurableField, ConfigurableFieldMultiOption, diff --git a/libs/langchain/langchain/smith/evaluation/runner_utils.py b/libs/langchain/langchain/smith/evaluation/runner_utils.py index 59f78b72d7bd3..38593e27b00f6 100644 --- a/libs/langchain/langchain/smith/evaluation/runner_utils.py +++ b/libs/langchain/langchain/smith/evaluation/runner_utils.py @@ -21,9 +21,9 @@ ) from langchain_core._api import warn_deprecated -from langchain_core.runnable import Runnable, RunnableConfig, RunnableLambda -from langchain_core.runnable import config as runnable_config -from langchain_core.runnable import utils as runnable_utils +from langchain_core.runnables import Runnable, RunnableConfig, RunnableLambda +from langchain_core.runnables import config as runnable_config +from langchain_core.runnables import utils as runnable_utils from langchain_core.schema import ChatResult, LLMResult from langchain_core.schema.language_model import BaseLanguageModel from langchain_core.schema.messages import BaseMessage, messages_from_dict diff --git a/libs/langchain/tests/integration_tests/llms/test_opaqueprompts.py b/libs/langchain/tests/integration_tests/llms/test_opaqueprompts.py index 9687af7a929b4..9fd257780931d 100644 --- a/libs/langchain/tests/integration_tests/llms/test_opaqueprompts.py +++ b/libs/langchain/tests/integration_tests/llms/test_opaqueprompts.py @@ -1,5 +1,5 @@ from langchain_core.prompts import PromptTemplate -from langchain_core.runnable import RunnableParallel +from langchain_core.runnables import RunnableParallel from langchain_core.schema.output_parser import StrOutputParser import langchain.utilities.opaqueprompts as op diff --git a/libs/langchain/tests/unit_tests/runnables/test_hub.py b/libs/langchain/tests/unit_tests/runnables/test_hub.py index 2d31bb2210694..f17700ef2c659 100644 --- a/libs/langchain/tests/unit_tests/runnables/test_hub.py +++ b/libs/langchain/tests/unit_tests/runnables/test_hub.py @@ -2,7 +2,7 @@ from unittest.mock import Mock, patch from langchain_core.prompts import ChatPromptTemplate -from langchain_core.runnable.base import ConfigurableField +from langchain_core.runnables.base import ConfigurableField from langchain.runnables.hub import HubRunnable