From 8365524fc87df3f5eb3808b5cb440aac4bbcaeb8 Mon Sep 17 00:00:00 2001 From: QuantumGhost Date: Tue, 24 Jun 2025 19:16:29 +0800 Subject: [PATCH] fix(api): add `version` class method for subclasses of `LLMNode`. `QuestionClassifierNode` and `KnowledgeRetrievalNode` are inherited from `LLMNode`, so they inherit the `version` method from `LLMNode`. However, the inheritence relationship is suboptimial and makes code less clear, creating a tight coupling with `LLMNode`. Here we explicitly add the `version` to those two classes, improving readibility and maintainability. --- .../nodes/knowledge_retrieval/knowledge_retrieval_node.py | 4 ++++ .../nodes/question_classifier/question_classifier_node.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py b/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py index 2995f0682f..0b9e98f28a 100644 --- a/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py +++ b/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py @@ -71,6 +71,10 @@ class KnowledgeRetrievalNode(LLMNode): _node_data_cls = KnowledgeRetrievalNodeData # type: ignore _node_type = NodeType.KNOWLEDGE_RETRIEVAL + @classmethod + def version(cls): + return "1" + def _run(self) -> NodeRunResult: # type: ignore node_data = cast(KnowledgeRetrievalNodeData, self.node_data) # extract variables diff --git a/api/core/workflow/nodes/question_classifier/question_classifier_node.py b/api/core/workflow/nodes/question_classifier/question_classifier_node.py index 1f50700c7e..a518167cc6 100644 --- a/api/core/workflow/nodes/question_classifier/question_classifier_node.py +++ b/api/core/workflow/nodes/question_classifier/question_classifier_node.py @@ -40,6 +40,10 @@ class QuestionClassifierNode(LLMNode): _node_data_cls = QuestionClassifierNodeData # type: ignore _node_type = NodeType.QUESTION_CLASSIFIER + @classmethod + def version(cls): + return "1" + def _run(self): node_data = cast(QuestionClassifierNodeData, self.node_data) variable_pool = self.graph_runtime_state.variable_pool