mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
feat(api): automatically NODE_TYPE_CLASSES_MAPPING generation from node class definitions (#28525)
This commit is contained in:
@ -130,7 +130,7 @@ class AppGenerateEntity(BaseModel):
|
||||
# extra parameters, like: auto_generate_conversation_name
|
||||
extras: dict[str, Any] = Field(default_factory=dict)
|
||||
|
||||
# tracing instance
|
||||
# tracing instance; use forward ref to avoid circular import at import time
|
||||
trace_manager: Optional["TraceQueueManager"] = None
|
||||
|
||||
|
||||
@ -275,16 +275,23 @@ class RagPipelineGenerateEntity(WorkflowAppGenerateEntity):
|
||||
start_node_id: str | None = None
|
||||
|
||||
|
||||
# Import TraceQueueManager at runtime to resolve forward references
|
||||
from core.ops.ops_trace_manager import TraceQueueManager
|
||||
# NOTE: Avoid importing heavy tracing modules at import time to prevent circular imports.
|
||||
# Forward reference to TraceQueueManager is kept as a string; we rebuild with a stub now to
|
||||
# avoid Pydantic forward-ref errors in test contexts, and with the real class at app startup.
|
||||
|
||||
# Rebuild models that use forward references
|
||||
AppGenerateEntity.model_rebuild()
|
||||
EasyUIBasedAppGenerateEntity.model_rebuild()
|
||||
ConversationAppGenerateEntity.model_rebuild()
|
||||
ChatAppGenerateEntity.model_rebuild()
|
||||
CompletionAppGenerateEntity.model_rebuild()
|
||||
AgentChatAppGenerateEntity.model_rebuild()
|
||||
AdvancedChatAppGenerateEntity.model_rebuild()
|
||||
WorkflowAppGenerateEntity.model_rebuild()
|
||||
RagPipelineGenerateEntity.model_rebuild()
|
||||
|
||||
# Minimal stub to satisfy Pydantic model_rebuild in environments where the real type is not importable yet.
|
||||
class _TraceQueueManagerStub:
|
||||
pass
|
||||
|
||||
|
||||
_ns = {"TraceQueueManager": _TraceQueueManagerStub}
|
||||
AppGenerateEntity.model_rebuild(_types_namespace=_ns)
|
||||
EasyUIBasedAppGenerateEntity.model_rebuild(_types_namespace=_ns)
|
||||
ConversationAppGenerateEntity.model_rebuild(_types_namespace=_ns)
|
||||
ChatAppGenerateEntity.model_rebuild(_types_namespace=_ns)
|
||||
CompletionAppGenerateEntity.model_rebuild(_types_namespace=_ns)
|
||||
AgentChatAppGenerateEntity.model_rebuild(_types_namespace=_ns)
|
||||
AdvancedChatAppGenerateEntity.model_rebuild(_types_namespace=_ns)
|
||||
WorkflowAppGenerateEntity.model_rebuild(_types_namespace=_ns)
|
||||
RagPipelineGenerateEntity.model_rebuild(_types_namespace=_ns)
|
||||
|
||||
Reference in New Issue
Block a user