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.
pull/21443/head
QuantumGhost 11 months ago
parent 1a1bfd4048
commit 8365524fc8

@ -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

@ -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

Loading…
Cancel
Save