From 6de3d6e83c7f13c7ac67fedbb3c51b37eedf0ddd Mon Sep 17 00:00:00 2001 From: Andrew Huang Date: Wed, 18 Sep 2024 15:55:12 -0700 Subject: [PATCH 1/2] fix langchain import --- panel/chat/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/panel/chat/__init__.py b/panel/chat/__init__.py index 8cac6e04cd..e01f3ab9e3 100644 --- a/panel/chat/__init__.py +++ b/panel/chat/__init__.py @@ -52,9 +52,10 @@ def __getattr__(name): """ Lazily import langchain module when accessed. """ + import importlib as _importlib + if name == "langchain": - from . import langchain - return langchain + return _importlib.import_module("panel.chat.langchain") raise AttributeError(f"module {__name__!r} has no attribute {name!r}") __dir__ = lambda: list(__all__) From c3821cf0b4dbb6b8150764788fe915012d1c627d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Thu, 19 Sep 2024 11:13:48 +0200 Subject: [PATCH 2/2] Apply suggestions from code review --- panel/chat/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/panel/chat/__init__.py b/panel/chat/__init__.py index e01f3ab9e3..b8b32e8028 100644 --- a/panel/chat/__init__.py +++ b/panel/chat/__init__.py @@ -52,10 +52,9 @@ def __getattr__(name): """ Lazily import langchain module when accessed. """ - import importlib as _importlib - if name == "langchain": - return _importlib.import_module("panel.chat.langchain") + import importlib + return importlib.import_module("panel.chat.langchain") raise AttributeError(f"module {__name__!r} has no attribute {name!r}") __dir__ = lambda: list(__all__)