From beb8f9a3930d8320490aeb2ac1d571231bed352b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 27 Mar 2024 22:08:30 -0300 Subject: [PATCH] Add get_schema method to Service class --- src/backend/base/langflow/services/base.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/backend/base/langflow/services/base.py b/src/backend/base/langflow/services/base.py index 301771944..594d697bc 100644 --- a/src/backend/base/langflow/services/base.py +++ b/src/backend/base/langflow/services/base.py @@ -5,6 +5,23 @@ class Service(ABC): name: str ready: bool = False + def get_schema(self): + """Build a dictionary listing all methods, their parameters, types, return types and documentation.""" + + schema = {} + ignore = ["teardown", "set_ready"] + for method in dir(self): + if method.startswith("_") or method in ignore: + continue + func = getattr(self, method) + schema[method] = { + "name": method, + "parameters": func.__annotations__, + "return": func.__annotations__.get("return"), + "documentation": func.__doc__, + } + return schema + def teardown(self): pass