Support latest langchain master

This commit is contained in:
Nuno Campos
2023-08-10 12:33:26 +01:00
parent b7692fc361
commit acd8265600
2 changed files with 5 additions and 7 deletions
+3 -2
View File
@@ -20,7 +20,8 @@ from typing import (
from langchain.callbacks.manager import CallbackManager
from langchain.load.dump import dumpd
from langchain.load.serializable import Serializable
from langchain.schema.runnable import Runnable, RunnableConfig, _patch_config
from langchain.schema.runnable import Runnable, RunnableConfig
from langchain.schema.runnable.base import patch_config
from permchain.connection import PubSubConnection
from permchain.topic import INPUT_TOPIC, OUTPUT_TOPIC, RunnableSubscriber
@@ -144,7 +145,7 @@ class PubSub(Serializable, Runnable[Any, Any], ABC):
process.invoke,
value,
config={
**_patch_config(
**patch_config(
config, run_manager.get_child(process.topic.name)
),
"send": send,
+2 -5
View File
@@ -19,9 +19,8 @@ from langchain.schema.runnable import (
RunnableConfig,
RunnablePassthrough,
RunnableSequence,
Other,
_coerce_to_runnable,
)
from langchain.schema.runnable.base import Other, coerce_to_runnable
from pydantic import Field
T = TypeVar("T")
@@ -81,9 +80,7 @@ class RunnableSubscriber(RunnableBinding[T, Any]):
| Mapping[str, Runnable[Any, Other] | Callable[[Any], Other]],
) -> RunnableSequence[T, Other]:
if isinstance(self.bound, RunnablePassthrough):
return RunnableSubscriber(
topic=self.topic, bound=_coerce_to_runnable(other)
)
return RunnableSubscriber(topic=self.topic, bound=coerce_to_runnable(other))
else:
return RunnableSubscriber(topic=self.topic, bound=self.bound | other)