From acd8265600db1b6e3de362b7efbc393c4d35a89b Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Thu, 10 Aug 2023 12:33:26 +0100 Subject: [PATCH] Support latest langchain master --- permchain/pubsub.py | 5 +++-- permchain/topic.py | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/permchain/pubsub.py b/permchain/pubsub.py index 52cfbe914..8a6c3f158 100644 --- a/permchain/pubsub.py +++ b/permchain/pubsub.py @@ -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, diff --git a/permchain/topic.py b/permchain/topic.py index dfbf2b025..c804e5c67 100644 --- a/permchain/topic.py +++ b/permchain/topic.py @@ -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)