diff --git a/src/langbot/pkg/discover/engine.py b/src/langbot/pkg/discover/engine.py index 713420d1..48923fe6 100644 --- a/src/langbot/pkg/discover/engine.py +++ b/src/langbot/pkg/discover/engine.py @@ -241,12 +241,14 @@ class ComponentDiscoveryEngine: return for file in importutil.list_resource_files(path): - if (not os.path.isdir(os.path.join(path, file))) and (file.endswith('.yaml') or file.endswith('.yml')): - comp = self.load_component_manifest(os.path.join(path, file), owner, no_save) + file_path = os.path.join(path, file) + is_dir = importutil.is_resource_dir(file_path) + if (not is_dir) and (file.endswith('.yaml') or file.endswith('.yml')): + comp = self.load_component_manifest(file_path, owner, no_save) if comp is not None: components.append(comp) - elif os.path.isdir(os.path.join(path, file)): - recursive_load_component_manifests_in_dir(os.path.join(path, file), depth + 1) + elif is_dir: + recursive_load_component_manifests_in_dir(file_path, depth + 1) recursive_load_component_manifests_in_dir(path) return components diff --git a/src/langbot/pkg/platform/adapters/telegram/manifest.yaml b/src/langbot/pkg/platform/adapters/telegram/manifest.yaml index 5ca602cd..772f7671 100644 --- a/src/langbot/pkg/platform/adapters/telegram/manifest.yaml +++ b/src/langbot/pkg/platform/adapters/telegram/manifest.yaml @@ -93,5 +93,5 @@ spec: execution: python: - path: pkg/platform/adapters/telegram/adapter.py + path: ./adapter.py attr: TelegramAdapter diff --git a/src/langbot/pkg/utils/importutil.py b/src/langbot/pkg/utils/importutil.py index a35052a6..a114d246 100644 --- a/src/langbot/pkg/utils/importutil.py +++ b/src/langbot/pkg/utils/importutil.py @@ -47,3 +47,10 @@ def read_resource_file_bytes(resource_path: str) -> bytes: def list_resource_files(resource_path: str) -> list[str]: return [f.name for f in importlib.resources.files('langbot').joinpath(resource_path).iterdir()] + + +def is_resource_dir(resource_path: str) -> bool: + try: + return importlib.resources.files('langbot').joinpath(resource_path).is_dir() + except (TypeError, FileNotFoundError): + return False diff --git a/src/langbot/templates/components.yaml b/src/langbot/templates/components.yaml index a95235aa..924fd8a4 100644 --- a/src/langbot/templates/components.yaml +++ b/src/langbot/templates/components.yaml @@ -10,6 +10,8 @@ spec: MessagePlatformAdapter: fromDirs: - path: pkg/platform/sources/ + - path: pkg/platform/adapters/ + maxDepth: 3 LLMAPIRequester: fromDirs: - path: pkg/provider/modelmgr/requesters/