This commit is contained in:
Typer_Body
2026-05-23 01:31:42 +08:00
parent 44fb188994
commit 127198675e
2 changed files with 22 additions and 1 deletions

View File

@@ -118,6 +118,28 @@ class WorkflowNode(abc.ABC):
registry = NodeTypeRegistry.instance()
return registry.get_metadata(self.type_name)
@classmethod
def to_schema(cls) -> dict[str, Any]:
"""Return a schema dict for this node type.
This is used by tests and tooling to inspect node capabilities.
"""
from .registry import NodeTypeRegistry
registry = NodeTypeRegistry.instance()
metadata = registry.get_metadata(cls.type_name)
if metadata:
return registry._metadata_to_schema(metadata)
# Fallback: build a minimal schema from class attributes
return {
'type': f'{cls.category}.{cls.type_name}' if cls.type_name else cls.type_name,
'category': cls.category,
'label': getattr(cls, 'name', cls.type_name),
'description': getattr(cls, 'description', ''),
'inputs': [],
'outputs': [],
'config_schema': [],
}
# ------------------------------------------------------------------
# Decorator and pending registration helpers

View File

@@ -5,7 +5,6 @@ Node metadata is loaded from: ../../templates/metadata/nodes/question_classifier
from __future__ import annotations
import json
import logging
from typing import Any