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