diff --git a/project/plugins/anomaly_detection.py b/project/plugins/anomaly_detection/anomaly_detection.py similarity index 100% rename from project/plugins/anomaly_detection.py rename to project/plugins/anomaly_detection/anomaly_detection.py diff --git a/project/plugins/anomaly_detection.yaml b/project/plugins/anomaly_detection/anomaly_detection.yaml similarity index 100% rename from project/plugins/anomaly_detection.yaml rename to project/plugins/anomaly_detection/anomaly_detection.yaml diff --git a/project/plugins/ascii_render/__init__.py b/project/plugins/ascii_render/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/plugins/ascii_render.py b/project/plugins/ascii_render/ascii_render.py similarity index 100% rename from project/plugins/ascii_render.py rename to project/plugins/ascii_render/ascii_render.py diff --git a/project/plugins/ascii_render.yaml b/project/plugins/ascii_render/ascii_render.yaml similarity index 100% rename from project/plugins/ascii_render.yaml rename to project/plugins/ascii_render/ascii_render.yaml diff --git a/project/plugins/document_retriever/__init__.py b/project/plugins/document_retriever/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/plugins/document_retriever.py b/project/plugins/document_retriever/document_retriever.py similarity index 100% rename from project/plugins/document_retriever.py rename to project/plugins/document_retriever/document_retriever.py diff --git a/project/plugins/document_retriever.yaml b/project/plugins/document_retriever/document_retriever.yaml similarity index 100% rename from project/plugins/document_retriever.yaml rename to project/plugins/document_retriever/document_retriever.yaml diff --git a/project/plugins/image2text/__init__.py b/project/plugins/image2text/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/plugins/image2text.py b/project/plugins/image2text/image2text.py similarity index 100% rename from project/plugins/image2text.py rename to project/plugins/image2text/image2text.py diff --git a/project/plugins/image2text.yaml b/project/plugins/image2text/image2text.yaml similarity index 100% rename from project/plugins/image2text.yaml rename to project/plugins/image2text/image2text.yaml diff --git a/project/plugins/klarna_search/__init__.py b/project/plugins/klarna_search/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/plugins/klarna_search.py b/project/plugins/klarna_search/klarna_search.py similarity index 100% rename from project/plugins/klarna_search.py rename to project/plugins/klarna_search/klarna_search.py diff --git a/project/plugins/klarna_search.yaml b/project/plugins/klarna_search/klarna_search.yaml similarity index 100% rename from project/plugins/klarna_search.yaml rename to project/plugins/klarna_search/klarna_search.yaml diff --git a/project/plugins/paper_summary/__init__.py b/project/plugins/paper_summary/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/plugins/paper_summary.py b/project/plugins/paper_summary/paper_summary.py similarity index 100% rename from project/plugins/paper_summary.py rename to project/plugins/paper_summary/paper_summary.py diff --git a/project/plugins/paper_summary.yaml b/project/plugins/paper_summary/paper_summary.yaml similarity index 100% rename from project/plugins/paper_summary.yaml rename to project/plugins/paper_summary/paper_summary.yaml diff --git a/project/plugins/speech2text/__init__.py b/project/plugins/speech2text/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/plugins/speech2text.py b/project/plugins/speech2text/speech2text.py similarity index 100% rename from project/plugins/speech2text.py rename to project/plugins/speech2text/speech2text.py diff --git a/project/plugins/speech2text.yaml b/project/plugins/speech2text/speech2text.yaml similarity index 100% rename from project/plugins/speech2text.yaml rename to project/plugins/speech2text/speech2text.yaml diff --git a/project/plugins/sql_pull_data/__init__.py b/project/plugins/sql_pull_data/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/plugins/sql_pull_data.py b/project/plugins/sql_pull_data/sql_pull_data.py similarity index 100% rename from project/plugins/sql_pull_data.py rename to project/plugins/sql_pull_data/sql_pull_data.py diff --git a/project/plugins/sql_pull_data.yaml b/project/plugins/sql_pull_data/sql_pull_data.yaml similarity index 100% rename from project/plugins/sql_pull_data.yaml rename to project/plugins/sql_pull_data/sql_pull_data.yaml diff --git a/project/plugins/tell_joke/__init__.py b/project/plugins/tell_joke/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/plugins/tell_joke.py b/project/plugins/tell_joke/tell_joke.py similarity index 100% rename from project/plugins/tell_joke.py rename to project/plugins/tell_joke/tell_joke.py diff --git a/project/plugins/tell_joke.yaml b/project/plugins/tell_joke/tell_joke.yaml similarity index 100% rename from project/plugins/tell_joke.yaml rename to project/plugins/tell_joke/tell_joke.yaml diff --git a/project/plugins/text2speech/__init__.py b/project/plugins/text2speech/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/plugins/text2speech.py b/project/plugins/text2speech/text2speech.py similarity index 100% rename from project/plugins/text2speech.py rename to project/plugins/text2speech/text2speech.py diff --git a/project/plugins/text2speech.yaml b/project/plugins/text2speech/text2speech.yaml similarity index 100% rename from project/plugins/text2speech.yaml rename to project/plugins/text2speech/text2speech.yaml diff --git a/project/plugins/text_classification/__init__.py b/project/plugins/text_classification/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/project/plugins/text_classification.py b/project/plugins/text_classification/text_classification.py similarity index 100% rename from project/plugins/text_classification.py rename to project/plugins/text_classification/text_classification.py diff --git a/project/plugins/text_classification.yaml b/project/plugins/text_classification/text_classification.yaml similarity index 100% rename from project/plugins/text_classification.yaml rename to project/plugins/text_classification/text_classification.yaml diff --git a/taskweaver/code_interpreter/code_executor.py b/taskweaver/code_interpreter/code_executor.py index d19eb9be..8f95921d 100644 --- a/taskweaver/code_interpreter/code_executor.py +++ b/taskweaver/code_interpreter/code_executor.py @@ -131,7 +131,7 @@ def _save_file( def load_plugin(self): for p in self.plugin_registry.get_list(): try: - src_file = f"{self.config.app_base_path}/plugins/{p.impl}.py" + src_file = f"{self.config.app_base_path}/plugins/{p.impl}/{p.impl}.py" with open(src_file, "r") as f: plugin_code = f.read() self.exec_client.load_plugin( diff --git a/taskweaver/memory/plugin.py b/taskweaver/memory/plugin.py index 8e82ed1f..7497731c 100644 --- a/taskweaver/memory/plugin.py +++ b/taskweaver/memory/plugin.py @@ -297,7 +297,7 @@ def provide_plugin_registry( ) -> PluginRegistry: import os - file_glob = os.path.join(config.base_path, "*.yaml") + file_glob = os.path.join(config.base_path, '**',"*.yaml") return PluginRegistry( file_glob=file_glob, ttl=timedelta(minutes=10), diff --git a/taskweaver/misc/component_registry.py b/taskweaver/misc/component_registry.py index 298fe1d7..e7a1db78 100644 --- a/taskweaver/misc/component_registry.py +++ b/taskweaver/misc/component_registry.py @@ -1,3 +1,4 @@ +import os from abc import ABC, abstractmethod from datetime import datetime, timedelta from typing import Dict, Generic, List, Optional, Tuple, TypeVar, Union @@ -33,6 +34,15 @@ def is_available(self, freshness: Optional[timedelta] = None) -> bool: return False return True + def _should_skip_plugin_file(self, path): + splitted_path = path.split(os.sep) + is_plugin = os.path.join('plugins','project') in path + is_plugin_yaml = splitted_path[-2] == splitted_path[-1].split('.')[0] + if is_plugin: + if not is_plugin_yaml: + return True + return False + def get_registry( self, force_reload: bool = False, @@ -45,6 +55,8 @@ def get_registry( registry: Dict[str, component_type] = {} for path in glob_files(self._file_glob): + if self._should_skip_plugin_file(path): + continue try: name, component = self._load_component(path) except ComponentDisabledException: