imbajin commented on code in PR #302: URL: https://github.com/apache/incubator-hugegraph-ai/pull/302#discussion_r2453915197
########## hugegraph-llm/src/hugegraph_llm/nodes/base_node.py: ########## @@ -0,0 +1,83 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from typing import Any, Dict, Optional +from PyCGraph import GNode, CStatus +from hugegraph_llm.nodes.util import init_context +from hugegraph_llm.state.ai_state import WkFlowInput, WkFlowState +from hugegraph_llm.utils.log import log + + +class BaseNode(GNode): Review Comment: 🧹 **Minor: BaseNode类缺少类型注解和文档字符串** ```python class BaseNode(GNode): context: WkFlowState = None wk_input: WkFlowInput = None ``` 建议改进: ```python from typing import Optional class BaseNode(GNode): """ 工作流节点基类,提供上下文管理和操作调度功能。 所有自定义节点应继承此类并实现 operator_schedule 方法。 Attributes: context: 工作流共享状态 wk_input: 工作流输入参数 """ context: Optional[WkFlowState] = None wk_input: Optional[WkFlowInput] = None def operator_schedule(self, data_json: dict) -> Optional[dict]: """ 子类必须实现的操作调度方法。 Args: data_json: 上下文序列化的JSON数据 Returns: 处理结果的字典,或None表示无更新 Raises: NotImplementedError: 子类未实现此方法 """ raise NotImplementedError("Subclasses must implement operator_schedule") ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
