|
|
@ -834,15 +834,15 @@ class RunnableBranch(Serializable, Runnable[Input, Output]):
|
|
|
|
class Config:
|
|
|
|
class Config:
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_serializable(self) -> bool:
|
|
|
|
def is_lc_serializable(cls) -> bool:
|
|
|
|
"""RunnableBranch is serializable if all its branches are serializable."""
|
|
|
|
"""RunnableBranch is serializable if all its branches are serializable."""
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_namespace(self) -> List[str]:
|
|
|
|
def get_lc_namespace(cls) -> List[str]:
|
|
|
|
"""The namespace of a RunnableBranch is the namespace of its default branch."""
|
|
|
|
"""The namespace of a RunnableBranch is the namespace of its default branch."""
|
|
|
|
return self.__class__.__module__.split(".")[:-1]
|
|
|
|
return cls.__module__.split(".")[:-1]
|
|
|
|
|
|
|
|
|
|
|
|
def invoke(self, input: Input, config: Optional[RunnableConfig] = None) -> Output:
|
|
|
|
def invoke(self, input: Input, config: Optional[RunnableConfig] = None) -> Output:
|
|
|
|
"""First evaluates the condition, then delegate to true or false branch."""
|
|
|
|
"""First evaluates the condition, then delegate to true or false branch."""
|
|
|
@ -946,13 +946,13 @@ class RunnableWithFallbacks(Serializable, Runnable[Input, Output]):
|
|
|
|
class Config:
|
|
|
|
class Config:
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_serializable(self) -> bool:
|
|
|
|
def is_lc_serializable(cls) -> bool:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_namespace(self) -> List[str]:
|
|
|
|
def get_lc_namespace(cls) -> List[str]:
|
|
|
|
return self.__class__.__module__.split(".")[:-1]
|
|
|
|
return cls.__module__.split(".")[:-1]
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def runnables(self) -> Iterator[Runnable[Input, Output]]:
|
|
|
|
def runnables(self) -> Iterator[Runnable[Input, Output]]:
|
|
|
@ -1184,13 +1184,13 @@ class RunnableSequence(Serializable, Runnable[Input, Output]):
|
|
|
|
def steps(self) -> List[Runnable[Any, Any]]:
|
|
|
|
def steps(self) -> List[Runnable[Any, Any]]:
|
|
|
|
return [self.first] + self.middle + [self.last]
|
|
|
|
return [self.first] + self.middle + [self.last]
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_serializable(self) -> bool:
|
|
|
|
def is_lc_serializable(cls) -> bool:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_namespace(self) -> List[str]:
|
|
|
|
def get_lc_namespace(cls) -> List[str]:
|
|
|
|
return self.__class__.__module__.split(".")[:-1]
|
|
|
|
return cls.__module__.split(".")[:-1]
|
|
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
class Config:
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
arbitrary_types_allowed = True
|
|
|
@ -1674,13 +1674,13 @@ class RunnableMap(Serializable, Runnable[Input, Dict[str, Any]]):
|
|
|
|
) -> None:
|
|
|
|
) -> None:
|
|
|
|
super().__init__(steps={key: coerce_to_runnable(r) for key, r in steps.items()})
|
|
|
|
super().__init__(steps={key: coerce_to_runnable(r) for key, r in steps.items()})
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_serializable(self) -> bool:
|
|
|
|
def is_lc_serializable(cls) -> bool:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_namespace(self) -> List[str]:
|
|
|
|
def get_lc_namespace(cls) -> List[str]:
|
|
|
|
return self.__class__.__module__.split(".")[:-1]
|
|
|
|
return cls.__module__.split(".")[:-1]
|
|
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
class Config:
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
arbitrary_types_allowed = True
|
|
|
@ -2061,13 +2061,13 @@ class RunnableEach(Serializable, Runnable[List[Input], List[Output]]):
|
|
|
|
class Config:
|
|
|
|
class Config:
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_serializable(self) -> bool:
|
|
|
|
def is_lc_serializable(cls) -> bool:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_namespace(self) -> List[str]:
|
|
|
|
def get_lc_namespace(cls) -> List[str]:
|
|
|
|
return self.__class__.__module__.split(".")[:-1]
|
|
|
|
return cls.__module__.split(".")[:-1]
|
|
|
|
|
|
|
|
|
|
|
|
def bind(self, **kwargs: Any) -> RunnableEach[Input, Output]:
|
|
|
|
def bind(self, **kwargs: Any) -> RunnableEach[Input, Output]:
|
|
|
|
return RunnableEach(bound=self.bound.bind(**kwargs))
|
|
|
|
return RunnableEach(bound=self.bound.bind(**kwargs))
|
|
|
@ -2117,13 +2117,13 @@ class RunnableBinding(Serializable, Runnable[Input, Output]):
|
|
|
|
class Config:
|
|
|
|
class Config:
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
arbitrary_types_allowed = True
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_serializable(self) -> bool:
|
|
|
|
def is_lc_serializable(cls) -> bool:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@classmethod
|
|
|
|
def lc_namespace(self) -> List[str]:
|
|
|
|
def get_lc_namespace(cls) -> List[str]:
|
|
|
|
return self.__class__.__module__.split(".")[:-1]
|
|
|
|
return cls.__module__.split(".")[:-1]
|
|
|
|
|
|
|
|
|
|
|
|
def _merge_config(self, config: Optional[RunnableConfig]) -> RunnableConfig:
|
|
|
|
def _merge_config(self, config: Optional[RunnableConfig]) -> RunnableConfig:
|
|
|
|
copy = cast(RunnableConfig, dict(self.config))
|
|
|
|
copy = cast(RunnableConfig, dict(self.config))
|
|
|
|